JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
|
This project (see ./examples/test_user_interaction/
) demonstrates different types of user-interactions in JKQTPlotter.
It contains a simple plot with two graphs and provides several widgets that allow to bind different user interactions to different events:
The source code of the main application can be found in test_user_interaction.cpp
.
The menu at the top of the window contains several of the QActions provided for user-interaction by JKQTBasePlotter:
The rest of the form contains several Qt widgets which switch diverse aspects of the plot style (log-axes, grid on/off ...) and allow to bind different actions to several defined events, e.g.
As you can see, this QComboBox registers one of the available actions to the event of a left-button single mouse click without having modifiers pressed at the same time. The slot that actually reconfigures the JKQTPlotter uses the methods JKQTPlotter::deregisterMouseDragAction() and JKQTPlotter::registerMouseDragAction() to achieve this effect.
You can play around with this example to find out about different types of user interactions. SOm of them are illustrated with animations below.
the default context menu contains a sub-menu that allows to switch every graph and and off:
Each JKQTPlotter contains a toolbar that is by default invisible and appears, when the mouse moves over a designated area at the top of the plot:
You can also use the checkboxes "enable toolbar" to disable this toolbar alltogether and "toolbar 'always on'" to switch the vanishing feature off and make it visible all the time.
The JKQTPlotter contains a small text display for the current mouse position (in plot coordinates) at the top of the graph:
You can move the viewport of the graph using the mouse ("jkqtpmdaPanPlotOnMove"-action). If you drag inside the plot window, you can move in both directions, if you drag over one of the coordinate axes, you can change the range of this axis only:
There are several options to zoom, using the mouse:
Again these actions are limited to a single axis, if the mouse is above that axis (and not inside the actual plot rectangle).
JKQTPlotter provides a pre-built ruler tool that measures x- and y-distance between the start and end point, as well as the length of the connecting line and the angle of that line.
JKQTPlotter provides a pre-built tool that, while the mouse button is pressed and the cursor is dragged over the plot, finds data points (of most graphs) near the mouse and displays their coordinates (and errors) inside a small tooltip:
You can also use the mouse to draw various geometricals forms. When you finish drawing, a single event is emitted for that form, which contains its size and position:
JKQTPlotter contains a standard context menu, which is shown if plot->setContextMenuMode(jkqtpcmmStandardContextMenu);
was set. It contains several standard ways of interacting with the plot, e.g. save to file, copy to clipboard, print, switch graph visibilities, ...
In addition JKQTPlotter provides several ways to customize this menu:
JKQTPlotter::addAction()
(i.e. using the default Qt mechanism) and/or by adding actions to the internal JKQTBasePlotter, using JKQTBasePlotter::registerAdditionalAction()
JKQTPlotter::contextMenuOPened(x,y,menu)
: In addition to the standard context menu, JKQTPlotter can also be configures to display a special, user-defined context menu. To do so, call plot->setContextMenuMode(jkqtpcmmSpecialContextMenu);
and set your menu, by calling plot->setSpecialContextMenu(menu)
. You can also combine the special menu and the standard menu, by calling plot->setContextMenuMode(jkqtpcmmStandardAndSpecialContextMenu);
.