JKQTPlotter
an extensive Qt4/Qt5 Plotter framework (including a fast variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
jkqtplotter.h
1 /*
2  Copyright (c) 2008-2019 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
3 
4 
5 
6  This software is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 2.1 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #include <QWidget>
22 #include <QVector>
23 #include <QSettings>
24 #include <QColor>
25 #include <QMap>
26 #include <QVector>
27 #include <QScrollArea>
28 #include <QVBoxLayout>
29 #include <QToolBar>
30 #include <QGridLayout>
31 #include <QListWidget>
32 #include <QListWidgetItem>
33 #include <QToolBar>
34 #include <QPointer>
35 #include <QTimer>
36 
37 #include <vector>
38 #include <cmath>
39 #include <iostream>
40 
41 #include "jkqtplotter/jkqtpbaseplotter.h"
42 #include "jkqtplotter/jkqtplotterstyle.h"
43 #include "jkqtplotter/jkqtpbaseplotterstyle.h"
44 #include "jkqtplotter/jkqtptools.h"
45 #include "jkqtplotter/jkqtplotter_imexport.h"
46 #include "jkqtplotter/gui/jkvanishqtoolbar.h"
47 #include <QKeyEvent>
48 
49 #ifndef JKQTPLOTTER_H
50 #define JKQTPLOTTER_H
51 
52 /** \brief initialized Qt-ressources necessary for JKQTPlotter
53  * \ingroup jkqtpplottersupprt
54 */
56 
57 
58 /** \brief plotter widget for scientific plots (uses JKQTBasePlotter to do the actual drawing)
59  * \ingroup jkqtpplotterclasses
60  *
61  * This class is a QWidget-wrapper around JKQTBasePlotter. It uses the tools from JKQTBasePlotter
62  * to display scientific plots. This class mostly adds the Widget for the output and adds different
63  * types of user interactions.
64  *
65  * <b>Please have a look at the documentation of JKQTBasePlotter for details on the management of graphs
66  * and the formating/styling of the plot and graphs!</b>
67  *
68  * The rest of this documentation ins split into sections that each treat a special topic, as outlines below:
69  *
70  * \tableofcontents
71  *
72  *
73  * \section JKQTPLOTTER_BASICUSAGE Basic Usage of JKQTPlotter
74  *
75  * JKQTPlotter is a plotter widget which wraps around a JKQTBasePlotter instanced that does the actual drawing.
76  * A basic usage of JKQTPlotter looks like this:
77  *
78  * \code{.cpp}
79  * // create a new JKQTPlotter instance
80  * JKQTPlotter* plot = new JKQTPlotter(parentWidget);
81  *
82  * // fill two vectors with dtaa for a graph:
83  * QVector<double> X, Y;
84  * fillDataVectors(X, Y);
85  *
86  * // make data available to the internal datastore of the plotter:
87  * size_t columnX=plot->getDatastore()->addCopiedColumn(X, "x");
88  * size_t columnY=plot->getDatastore()->addCopiedColumn(Y, "y");
89  *
90  * // create a graph/curve, which displays the data
91  * JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(plot);
92  * graph1->setXColumn(columnX);
93  * graph1->setYColumn(columnY);
94  * graph1->setTitle(QObject::tr("graph title"));
95  * plot->addGraph(graph1);
96  *
97  * // autoscale the plot
98  * plot->zoomToFit();
99  * // alternatively set the axis dimension by hand:
100  * plot->setXY(-10,10,-10,10);
101  * \endcode
102  *
103  * The result should look something like this:
104  *
105  * \image html jkqtplotter_simpletest1.png
106  *
107  * Starting from this basic example, you can observe several important principles:
108  * # Data is stored in an (internal) instance of JKQTPDatastore, which is accessible through
109  * JKQTPlotter::getDatastore().
110  * This datastore can either own its data (which is done here, as we copy the data into the store
111  * by calling JKQTPDatastore::addCopiedColumn(), or it can merely reference to the data (then
112  * data needs to be available as array of \c double values).
113  * # Naming conventions:
114  * - \b plot is the complete drawn image, including the axes, the graphs, the key and all other visual elements
115  * - <b>plot element</b> any sub element of the plot, e.g. a single coordinate axis, the key, but also any graph/curve
116  * - \b graph is a single curve/image/geometric element in the plot
117  * - <b>geometric element</b> is a special graph that does not represent a curve based on data from the JKQTPDatastore,
118  * but a single graphic element, like a rectangle/circle/line/..., some text, a single symbol
119  * - \b key is the legend of the plot
120  * - <b>coordinate axis</b> is each of the x- or y-axis (there might be addition axes, e.g. when showing a color-scale)
121  * .
122  * # Each graph is represented by a class derived from JKQTPPlotElement (in the example we instanciated a JKQTPXYLineGraph,
123  * which shows data as a scatter of symbols that may (or may not) be connected by a line).
124  * Creating the graph class does not yet add it to the plotter. To add it, call JKQTPlotter::addGraph(). Only
125  * after this sep, the graph is displayed. You can modify the apperance of the graph (e.g. colors,
126  * name in the key ...) by setting properties in the graph class instance.
127  * # You can auto-zoom the axis ranges of the plot by calling JKQTPlotter::zoomToFit(), or set them
128  * exlicitly by calling JKQTPlotter::setXY(). The user can later zoom in/out by the mouse (and other means).
129  * You can limit this zoom range by setting an absolute axis range, calling e.g. JKQTPlotter::setAbsoluteXY().
130  * The the user cannot zoom farther out than the given range(s).
131  * # If you want to style the plot itself, you need to set properties of the underlying JKQTBasePloter instance, which
132  * is accessible through JKQTPlotter::getPlotter(). If you want to style the coordinate axes, you can acces their
133  * representing objects by caling JKQTPlotter::getXAxis() or JKQTPlotter::getYAxis().
134  * .
135  *
136  * \see \ref JKQTPlotterSimpleTest and \see JKQTPlotterQtCreator
137  *
138  * \section JKQTPLOTTER_SYNCMULTIPLOT Synchronizing Several Plots
139  *
140  * Often a single plot is not sufficient, but several plots need to be aligned with respect to each other:
141  *
142  * \image html test_multiplot.png
143  *
144  * In the Qt Window this is achieved by placing several JKQTPlotter objects into a <a href="http://doc.qt.io/qt-5/qgridlayout.html">QGridLayout</a>.
145  * In order to support this alignment, also when exporting/printing a plot, and when the user interactions with the plot (e.g. zooming),
146  * JKQTPlotter offers an API which allows to :
147  * <ul>
148  * <li> <b>declare (grid-like) relations between plots for export/printing</b>
149  * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentPos() and \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_SYNC</li>
150  * <li> <b>synchronize axes/plots</b>
151  * \see synchronizeXToMaster(), synchronizeYToMaster(), resetMasterSynchronization() and \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT</li>
152  * </ul>
153  *
154  *
155  * \note This API adopts and extends the possibilities of JKQTBasePlotter. Please see the documentation there for details:
156  * <ul>
157  * <li> \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
158  * <ul>
159  * <li> \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_SYNC</li>
160  * <li> \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT</li>
161  * </ul>
162  * </ul>
163  *
164  *
165  *
166  * \section JKQTPLOTTER_USERINTERACTION User-Interactions/GUI Features
167  *
168  * JKQTPlotter offers a lot of user-interaction features out of the box. These are detailed below.
169  *
170  * \subsection JKQTPLOTTER_CONTEXTMENU Context Menu of JKQTPlotter
171  *
172  * The class JKQTPlotter has a context menu that already offers a lot of functionality.
173  *
174  * \image html jkqtplotter_defaultcontextmenu.png
175  *
176  * \image html contextmenu_graphvisibility.gif
177  *
178  * It allows to:
179  * <ul>
180  * <li> copy or save the data from the internal JKQTPDatastore</li>
181  * <li> copy or save the plot to an image file (PNG, PDF, ...), includes a softisticated export-preview dialog:
182  *
183  * \image html jkqtplotter_exportpreviewdialog.png
184  * </li>
185  * <li> print the plot (includes a softisticated print-preview dialog):
186  *
187  * \image html jkqtplotter_printpreview.png "Print Preview Dialog"
188  *
189  * \image html jkqtplotter_printpreview_relsize_mullinewidth_mulfonts.png "Print Preview Dialog with modified (relative) size, line-width and font-size"
190  * </li>
191  * <li> open a dialog with a table of the plot data:
192  *
193  * \image html jkqtplotter_datatabledialog.png "Data Table Dialog (with buttons to save or copy the data)"
194  * </li>
195  * <li> zoom into/out of the plot and determine an auto-zoom, which shows all of the plot data</li>
196  * <li> switch the visibility of the different graphs in the plot</li>
197  * </ul>
198  *
199  * You can activate this menu, by setting \c setContextMenuMode(jkqtpcmmStandardContextMenu); and binding a mouse-action (typically the right-click)
200  * to the context menu by calling \c deregisterMouseDragAction(Qt::RightButton,Qt::NoModifier) which deregisters any user actions from the rhs single
201  * mouse click. In that case, the context menu is opened by default (see setContextMenuMode() to choose the mode of the context menu).
202  *
203  *
204  * In addition JKQTPlotter provides several ways to customize this menu:
205  * - You can add additional actions to the JKQTPlotter, by calling `JKQTPlotter::addAction()` (i.e. using the default Qt mechanism)
206  * and/or by adding actions to the internal JKQTBasePlotter, using `JKQTBasePlotter::registerAdditionalAction()`
207  * - You can modify the menu, when it is displayed, by connecting a slot to the signal `JKQTPlotter::contextMenuOPened(x,y,menu)`:
208  * \code
209  * connect(plot, SIGNAL(contextMenuOpened(double, double, QMenu*)), this, SLOT(contextMenuOpened(double, double, QMenu*)));
210  *
211  * // ...
212  *
213  * void TestUserInteraction::contextMenuOpened(double x, double y, QMenu *contextMenu)
214  * {
215  * contextMenu->addSeparator();
216  * QAction* act=contextMenu->addMenu(QString("contextMenuOpened(x=%1, y=%2)").arg(x).arg(y))->addAction("user-added action");
217  * connect(act, &QAction::triggered, [x,y]() { QMessageBox::warning(nullptr, tr("Plot Context Menu"),
218  * tr("Context Menu was opened at x/y=%1/%2!").arg(x).arg(y),
219  * QMessageBox::Ok,
220  * QMessageBox::Ok); });
221  * labMouseAction->setText(QString("contextMenuOpened(x=%1, y=%2)").arg(x).arg(y));
222  * }
223  * \endcode
224  * .
225  *
226  * \subsection JKQTPLOTTER_SPECIALCONTEXTMENU Special (User-Defined) Context Menu of JKQTPlotter
227  *
228  * In addition to the standard context menu, JKQTPlotter can also be configures to display a special, user-defined context menu.
229  * To do so, call `\c setContextMenuMode(jkqtpcmmSpecialContextMenu) and set your menu, by calling \c setSpecialContextMenu()
230  * You can also combine the special menu and the standard menu, by calling \c setContextMenuMode(jkqtpcmmStandardAndSpecialContextMenu) .
231  *
232  * You can also use the signal contextMenuOpened() to modify the special context menu, but note that alterations to this menu are permanently
233  * stored in the special menu object. See contextMenuOpened() for a detailed discussion and ways to circumvent this!
234  *
235  *
236  * \subsection JKQTPLOTTER_TOOLBAR Toolbar of JKQTPlotter
237  *
238  * In addition to the context-menu, a JKQtPlotter also also provides a toolbar at its top that offers
239  * most of the functionality of the context menu. Usually this toolbar is enabled (see toolbarEnabled)
240  * and is in a mode where it is hidden, until the mouse moves over an area at the top of the plot (see toolbarAlwaysOn):
241  *
242  * \image html jkqtplotter_toolbar_hidden.png "Hidden Toolbar"
243  * \image html jkqtplotter_toolbar_shown.png "Shown Toolbar"
244  *
245  * \image html jkqtvanishtoolbar.gif
246  *
247  * If toolbarAlwaysOn is set to \c true (setToolbarAlwaysOn() ), the toolbar is always displayed:
248  *
249  * \image html jkqtplotter_toolbar_alwayson.png
250  *
251  * \see toolbarEnabled, toolbarAlwaysOn, \ref JKQTPlotterUserInteraction
252  *
253  *
254  *
255  * \subsection JKQTPLOTTER_ACTIONS QActions from a JKQTPlotter
256  * Often you want to allow the suer to operate a plot from a user-defined QToolBar or a QMenu/QMenuBar in your
257  * application (e.g. provide zooming commands ...). there are generally two ways to achieve this:
258  * <ol>
259  * <li> Simply connect home-brewn QAction instances to the slots provided by JKQTPlotter and JKQTBasePlotter.
260  * This also allows you to connect different plot properties to edit widgets in your forms.
261  * \code
262  * // add a checkbox to show and hide the position display label in the plot
263  * chkPositionDisplay=new QCheckBox(tr("show mouse cursor position"), this);
264  * chkPositionDisplay->setChecked(plot->isMousePositionShown());
265  * connect(chkPositionDisplay, SIGNAL(toggled(bool)), plot, SLOT(setMousePositionShown(bool)));
266  * \endcode
267  * </li>
268  * <li> For several functions (especially those also present in JKQTPlotter's context-emun, you can also find
269  * readily available QAction instances. these are available from JKQTBasePlotter (e.g. by JKQTBasePlotter::getActionPrint() ...).
270  * From JKQTPlotter you therefor have to use: <code>getPlotter()->getActionPrint()</code>
271  * \code
272  * // add some of the default QActions from the JKQTPlotter to the window menu
273  * // Some of the are also available in the context menu and toolbar of the JKQTPlotter
274  * // others are not
275  * QMenu* menuPlot=menuBar()->addMenu("Plot-Menu");
276  * menuPlot->addAction(plot->getPlotter()->getActionPrint());
277  * QMenu* menuPlotS=menuPlot->addMenu("Save ...");
278  * menuPlotS->addAction(plot->getPlotter()->getActionSaveData());
279  * menuPlotS->addAction(plot->getPlotter()->getActionSavePDF()); // not available from JKQTPlotter by default
280  * menuPlotS->addAction(plot->getPlotter()->getActionSavePlot());
281  * \endcode
282  * </li>
283  * </ol>
284  * \see \ref JKQTPlotterUserInteraction
285  *
286  *
287  *
288  * \subsection JKQTPLOTTER_USERMOUSEINTERACTION Mouse-Interaction in JKQTPlotter
289  *
290  * This section summarizes all user-interaction functions in JKQTPlotter that somehow relate to the mouse.
291  * These are:
292  * - \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG
293  * - \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSECLICK
294  * - \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEWHEEL
295  * - \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE
296  * .
297  *
298  * \note Zooming and Paning interactions apply to both axes when they are performed with the mouse
299  * inside the plot. They are limited to one of the two axes, when the mouse hovers over that axis
300  * (e.g. when you zoom by mouse-wheel while the mouse pointer is below the plot, over the x-axis,
301  * only the x-axis is affected by the operation).
302  *
303  * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG Actions When Dragging the Mouse
304  * JKQTPlotter offers several methods that allow to customize, how it reacts to mouse actions:
305  * - registerMouseDragAction() tells JKQTPlotter to perform a certain action (selected from JKQTPlotter::MouseActionMode)
306  * when a specified mouse button is pushed while a specified (or no) keyborad modifiers (e.g. CTRL,ALT,SHIFT...) is pressed.
307  * By default JKQTPlotter calls these two registers in its constructors:
308  * \code
309  * registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, JKQTPlotter::MouseActionMode::jkqtpmdaZoomByRectangle);
310  * registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, JKQTPlotter::MouseActionMode::jkqtpmdaPanPlotOnMove);
311  * \endcode
312  * Therefore by default you can draw a zoom rectangle with the left mouse button without modifiers
313  * and you can pan/drag the plot with the left mouse-button while keeping CTRL pressed.
314  * - deregisterMouseDragAction() deletes a previously defined user-interaction
315  * - clearAllRegisteredMouseDragActions() deletes all previously specified user-actions
316  * .
317  *
318  * Pressing the \c ESC key will stop the current JKQTPlotter::MouseActionMode.
319  *
320  * If e.g. the mode JKQTPlotter::MouseActionMode::jkqtpmdaZoomByRectangle is selected, while you drag the mouse, the
321  * zoom rectangle is drawn over the plot. You can modify the style of drawing using these functions:
322  * - setUserActionOverlayPen() sets the pen for (semi-transparent) overlay shapes, e.g. zoom rectangles
323  * - setUserActionOverlayBrush() sets the brush for (semi-transparent) overlay shapes, e.g. zoom rectangles
324  * - setUserActionOpaquePen() sets the pen for opaque overlay shapes, e.g. tool-tips
325  * - setUserActionOpaqueBrush() sets the brush for opaque overlay shapes, e.g. tool-tips
326  * - setUserActionMarkerPen() sets the pen for marker overlay shapes, e.g. with tool-tips
327  * - setUserActionMarkerBrush() sets the brush for marker overlay shapes, e.g. with tool-tips
328  * - setUserActionMarkerDiameter() sets the size of user-action markers
329  * - setUserActionMarkerType() sets the type of user-action markers
330  * .
331  *
332  * \image html zoomin_mouse_contextmenu.gif "Zooming with the mouse"
333  *
334  * \image html draw_rectangle.gif "Draw Rectangle User-Action"
335  *
336  * \image html drag_viewport.gif "Drag the Plot Viewport"
337  *
338  * \image html rulertool.gif "Measurement Ruler Tool"
339  *
340  * \image html tooltiptool.gif "Data Point Tooltip Tool"
341  *
342  *
343  * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_MOUSECLICK Actions After (Double-)Clicks on the Mouse Buttons
344  * The right mouse button has a special role: If it is single-clicked and no JKQTPlotter::MouseActionMode is specified
345  * for the vent, it opens the context menu, unless you call \c setContextMenuMode(jkqtpcmmNoContextMenu) .
346  * You can also use setContextMenuMode() to specify which type of context menu is shown. See JKQTPContextMenuModes
347  * for details on the available modes.
348  *
349  * For any mouse-click, one of the following signals is emitted:
350  * - plotMouseClicked() for any single-click (during the pressDown-Event!)
351  * - plotMouseDoubleClicked() for any double-click
352  * .
353  *
354  * The reaction to double-clicks of the mouse buttons can be specified separately. The possible
355  * actions are listed in JKQTPMouseDoubleClickActions. You can bind one of these actions
356  * to a specific click with these functions:
357  * - registerMouseDoubleClickAction() tells JKQTPlotter to perform a certain action (selected from JKQTPMouseDoubleClickActions)
358  * when a specified mouse button is pushed while a specified (or no) keyborad modifiers (e.g. CTRL,ALT,SHIFT...) is pressed.
359  * By default JKQTPlotter calls this in its constructors:
360  * \code
361  * registerMouseDoubleClickAction(Qt::LeftButton, Qt::NoModifier, JKQTPMouseDoubleClickActions::jkqtpdcaClickMovesViewport);
362  * \endcode
363  * Therefore by default you can pan the plot/move the viewport by double clicking a location
364  * - deregisterMouseDoubleClickAction() deletes a previously defined user-interaction
365  * - clearAllRegisteredMouseDoubleClickAction() deletes all previously specified user-actions
366  * .
367  * The button to react to is specified as a parameter.
368  *
369  * \image html contextmenu_graphvisibility.gif
370  *
371  * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEWHEEL Actions When a Mouse Wheel Event Occurs
372  * The actions to be performed when the mouse hweel is operated are specified in JKQTPMouseWheelActions.
373  * You can bind one of these actions to the mouse-wheel (under the condition that a specified Qt::KeyboardModifiers
374  * is pressed) by using these functions:
375  * - registerMouseWheelAction() tells JKQTPlotter to perform a certain action (selected from JKQTPMouseWheelActions)
376  * when a specified mouse button is pushed while a specified (or no) keyborad modifiers (e.g. CTRL,ALT,SHIFT...) is pressed.
377  * By default JKQTPlotter calls this in its constructors:
378  * \code
379  * registerMouseWheelAction(Qt::NoModifier, JKQTPMouseWheelActions::jkqtpmwaZoomByWheel);
380  * \endcode
381  * Therefore by default you can zoom into and out of the plot, using the mouse wheel.
382  * - deregisterMouseWheelAction() deletes a previously defined user-interaction
383  * - clearAllMouseWheelActions() deletes all previously specified user-actions
384  * .
385  * In addition the signal void plotMouseWheelOperated() is emitted whenever a mouse-wheel event occurs.
386  *
387  *
388  * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE Signaling When Mouse Moves
389  * In addition the signal plotMouseMove() is called whenever the mouse moves over the plot.
390  * Additional signals may be emitted, depending on the currently active JKQTPlotter::MouseActionMode.
391  *
392  * Also the current mouse position is shown above the graph by default (can be switched on or off
393  * using setMousePositionShown() ).
394  *
395  * \image html mousepositiondisplay.gif
396  *
397  *
398  * \subsubsection JKQTPLOTTER_USERMOUSEINTERACTION_FASTRESIZING Fast Resizing of a Plot Widget
399  * When the user resized the widget, the graph would in principle have to be readrawn for every intermediate step.
400  * As this is very timeconsuming, JKQTPlotter uses a different approach: Actual Redrawing is delayed a few 100ms
401  * and this delay is reset whenever the widget size changes. Only after the last delay expires, the plot is redrawn.
402  * In between an image of the last state of the plot is simple stretched/compressed to fill the new/current
403  * widget size. In sum this looks like this:
404  *
405  * \image html jkqtplotter_fastresizing.gif
406  *
407  *
408  *
409  *
410  * \section JKQTPLOTTER_USEQTCREATOR How to use JKQTPlotter in the Qt Form Designer
411  *
412  * As JKQTPlotter is a standard Qt widget, you can also use it in Qt UI-files designed with the Qt From Designer (e.g. from within QTCreator).
413  * For this to work you have to use the <a href="http://doc.qt.io/archives/qt-4.8/designer-using-custom-widgets.html">Promote QWidget"-feature</a> of the form designer. The steps you need to take are detailed below:
414  * <ol>
415  * <li> add a new UI-file to your project and open it in the Form Editor. Then right-click the form and select `Promote Widgets ...`:
416  *
417  * \image html uidesigner_step1.png
418  * </li>
419  * <li> In the dialog that opens, you have to define `JKQTPlotter` as a promotion to `QWidget` as shown below. Finally store the settings by clicking `Add` and closing the dialog with `Close`.
420  *
421  * \image html uidesigner_step2.png
422  * </li>
423  * <li> Now you can add a `QWidget`from the side-bar to the form and then promote it to `JKQTPlotter`, by selecting and right-clicking the `QWidget` and then selecting `Promote To | JKQTPlotter`:
424  *
425  * \image html uidesigner_step3.png
426  * </li>
427  * </ol>
428  *
429  * \see \ref JKQTPlotterQtCreator <br> Also see \ref JKQTPlotterStyling for another example of using the Qt UI Designer with JKQTPlotter
430  *
431  */
432 class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget {
433  Q_OBJECT
434  public:
435  /** \brief class constructor
436  *
437  * If \a datastore_internal \c ==false, you can supply an external JKQTPDatastore with the parameter \a datast
438  */
439  explicit JKQTPlotter(bool datastore_internal, QWidget* parent=nullptr, JKQTPDatastore* datast=nullptr);
440  /** \brief class constructor for a JKQTPlotter using an external JKQTPDatastore \a dataset
441  */
442  explicit JKQTPlotter(JKQTPDatastore* datast, QWidget* parent=nullptr);
443  /** \brief class constructor
444  *
445  * generated a new internal JKQTPDatastore
446  */
447  explicit JKQTPlotter(QWidget* parent=nullptr);
448 
449  /** \brief class destructor */
450  virtual ~JKQTPlotter();
451 
452  /** reinitializes the toolbar, i.e. fills in QActions added to the QWidget since its creation/the last call to this function */
453  void updateToolbarActions();
454 
455 
456  /** \brief set the width/height of the icons in the toolbar in pt */
457  void setToolbarIconSize(int value);
458 
459  /** \brief get the width/height of the icons in the toolbar in pt */
460  int getToolbarIconSize();
461 
462  /** \brief returns the class internally used for plotting */
463  JKQTBasePlotter* getPlotter() const { return plotter; }
464  /** \brief returns the class internally used for plotting */
465  const JKQTBasePlotter* getConstplotter() const { return const_cast<const JKQTBasePlotter*>(plotter); }
466 
467  /** \brief returns whether the toolbar is enabled
468  *
469  * \copydetails JKQTPlotterStyle::toolbarEnabled
470  *
471  * \see setToolbarEnabled(), JKQTPlotterStyle::toolbarEnabled
472  */
473  bool isToolbarEnabled() const;
474  /** \brief returns whether the toolbar is always visible or only when the mouse moves to the upper left area
475  *
476  * \copydetails JKQTPlotterStyle::toolbarAlwaysOn
477  *
478  * \see setToolbarAlwaysOn(), JKQTPlotterStyle::toolbarAlwaysOn
479  */
480  bool isToolbarAlwaysOn() const;
481  /** \brief specifies whether to display the current position of the mouse in the top border of the plot (this may automatically extent the
482  * top border, so the position fits in. The default widget font is used for the output.
483  *
484  * \copydetails JKQTPlotterStyle::displayMousePosition
485  *
486  * \see setMousePositionShown(), JKQTPlotterStyle::displayMousePosition, \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE */
487  bool isMousePositionShown() const;
488 
489  /** \copydoc JKQTPlotterStyle::userActionOverlayPen
490  *
491  * \see setUserActionOverlayPen(), getUserActionOverlayPen(), JKQTPlotterStyle::userActionOverlayPen \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
492  QPen getUserActionOverlayPen() const;
493 
494  /** \copydoc JKQTPlotterStyle::userActionOverlayBrush
495  *
496  * \see setUserActionOverlayBrush(), getUserActionOverlayBrush(), JKQTPlotterStyle::userActionOverlayBrush \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
497  QBrush getUserActionOverlayBrush() const;
498 
499  /** \copydoc JKQTPlotterStyle::userActionOpaquePen
500  *
501  * \see setUserActionOpaquePen(), getUserActionOpaquePen(), JKQTPlotterStyle::userActionOpaquePen \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
502  QPen getUserActionOpaquePen() const;
503 
504  /** \copydoc JKQTPlotterStyle::userActionOpaqueBrush
505  *
506  * \see setUserActionOpaqueBrush(), getUserActionOpaqueBrush(), JKQTPlotterStyle::userActionOpaqueBrush \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
507  QBrush getUserActionOpaqueBrush() const;
508 
509  /** \copydoc JKQTPlotterStyle::userActionMarkerPen
510  *
511  * \see setUserActionMarkerPen(), getUserActionMarkerPen(), JKQTPlotterStyle::userActionMarkerPen \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
512  QPen getUserActionMarkerPen() const;
513 
514  /** \copydoc JKQTPlotterStyle::userActionMarkerBrush
515  *
516  * \see setUserActionMarkerBrush(), getUserActionMarkerBrush(), JKQTPlotterStyle::userActionMarkerBrush \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
517  QBrush getUserActionMarkerBrush() const;
518 
519  /** \copydoc JKQTPlotterStyle::maxTooltipDistance */
520  int getMaxTooltipDistance() const;
521 
522  /** \copydoc JKQTPlotterStyle::userActionCatchSensitivity */
523  int getUserActionCatchSensitivity() const;
524 
525  /** \copydoc JKQTPlotterStyle::userActionMarkerDiameter */
526  int getUserActionMarkerDiameter() const;
527 
528  /** \copydoc JKQTPlotterStyle::userActionMarkerType */
529  JKQTPUserActionMarkerType getUserActionMarkerType() const;
530 
531 
532  /** \brief loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object */
533  void loadSettings(const QSettings &settings, const QString& group=QString("plots/"));
534 
535  /** \brief saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object.
536  *
537  * This method only saves those properties that differ from their default value.
538  */
539  void saveSettings(QSettings& settings, const QString& group=QString("plots/")) const;
540 
541  /** \brief returns the minimum size of the widget */
542  QSize minimumSizeHint() const;
543 
544  /** \brief returns the size of the widget */
545  QSize sizeHint() const;
546 
547 
548 
549 
550 
551  /*! \brief synchronize the plot borders (and zooming) with a given plotter (master --> slave/this)
552 
553  This function allows two plotters to draw a graph with exactly the same height or width
554  as in another graph. For example if you want to have two plotters which are positioned one
555  above the other (and have the same widget widths, which could be guaranteed by a QLayout)
556  you may want to make sure that their plotWidth s are always the same. In this case call
557  \code plotter2->synchronizeToMaster(plotter1, sdXAxis, true) \endcode of the lower plotter \c plotter2 .
558  Now whenever the size of plotter1 changes, also plotter2 is redrawn with the changed
559  borders.
560 
561  \image html jkqtbaseplotter_synchronization.png "Different Synchronization Settings for synchronizeDirection=sdXAxis"
562 
563  \param master the plotter widget to synchronize to
564  \param synchronizeDirection direction in which to synchronize
565  \param synchronizeAxisLength do you want the axis length to be synchronized?
566  \param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave
567  \param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master
568 
569  \see synchronizeXToMaster(), synchronizeYToMaster(), resetMasterSynchronization(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
570  */
571  void synchronizeToMaster(JKQTPlotter* master, JKQTBasePlotter::SynchronizationDirection synchronizeDirection, bool synchronizeAxisLength=true, bool synchronizeZoomingMasterToSlave=true, bool synchronizeZoomingSlaveToMaster=true);
572 
573  /*! \brief synchronize the plot x-axis width (and x-zooming) with a given master plotter (master --> slave/this)
574 
575  \param master the plotter widget to synchronize to
576  \param synchronizeAxisLength do you want the axis length to be synchronized?
577  \param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave
578  \param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master
579 
580  \image html jkqtbaseplotter_synchronization.png "Different Synchronization Settings for synchronizeDirection=sdXAxis"
581 
582  \note This is a short-cut to synchronizeToMaster() with \c synchronizeDirection=csXAxis
583  \see synchronizeToMaster(), synchronizeYToMaster(), resetMasterSynchronization(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
584  */
585  void synchronizeXToMaster(JKQTPlotter* master, bool synchronizeAxisLength=true, bool synchronizeZoomingMasterToSlave=true, bool synchronizeZoomingSlaveToMaster=true);
586 
587  /*! \brief synchronize the plot y-axis height (and y-zooming) with a given master plotter (master --> slave/this)
588 
589  \param master the plotter widget to synchronize to
590  \param synchronizeAxisLength do you want the axis length to be synchronized?
591  \param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave
592  \param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master
593 
594  \note This function internally calls JKQTBasePlotter::synchronizeToMaster()
595  \note This is a short-cut to synchronizeToMaster() with \c synchronizeDirection=csXAxis
596  \see synchronizeToMaster(), synchronizeXToMaster(), resetMasterSynchronization(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
597 
598  */
599  void synchronizeYToMaster(JKQTPlotter* master, bool synchronizeAxisLength=true, bool synchronizeZoomingMasterToSlave=true, bool synchronizeZoomingSlaveToMaster=true);
600 
601  /** \brief switches any synchronization off, that has been created by synchronizeToMaster()
602  *
603  * \note This function internally calls JKQTBasePlotter::synchronizeToMaster()
604  \see synchronizeToMaster(), synchronizeXToMaster(), resetMasterSynchronization(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
605  */
606  void resetMasterSynchronization(JKQTBasePlotter::SynchronizationDirection synchronizeDirection=JKQTBasePlotter::sdXYAxes);
607 
608 
609  /*! \brief enables grid-printing for this plot
610  *
611  * \note This function call forwards to JKQTBasePlotter::setGridPrinting()
612  * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentPos(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
613  */
614  void setGridPrinting(bool enabled);
615 
616  /** \brief add a new plotter \a plotterOther for grid printing mode, at location \a x / \a y
617  *
618  * \note This function call forwards to JKQTBasePlotter::addGridPrintingPlotter()
619  * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentPos(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
620  */
621  void addGridPrintingPlotter(size_t x, size_t y, JKQTPlotter* plotterOther) ;
622 
623  /** \brief clear all additional plotters for grid printing mode
624  *
625  * \note This function call forwards to JKQTBasePlotter::clearGridPrintingPlotters()
626  * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentPos(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
627  */
628  void clearGridPrintingPlotters() ;
629  /** \brief set the x-position of this JKQTPlotter in the grid-printing grid
630  *
631  * \note This function call forwards to JKQTBasePlotter::setGridPrintingCurrentX()
632  * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentPos(), setGridPrintingCurrentY(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
633  */
634  void setGridPrintingCurrentX(size_t x);
635  /** \brief set the y-position of this JKQTPlotter in the grid-printing grid
636  *
637  * \note This function call forwards to JKQTBasePlotter::setGridPrintingCurrentY()
638  * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentPos(), setGridPrintingCurrentX(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
639  */
640  void setGridPrintingCurrentY(size_t y);
641  /** \brief set the x- and y-positions of this JKQTPlotter in the grid-printing grid
642  *
643  * \note This function call forwards to JKQTBasePlotter::setGridPrintingCurrentPos()
644  * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentX(), setGridPrintingCurrentY() \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
645  */
646  void setGridPrintingCurrentPos(size_t x, size_t y);
647 
648 
649 
650  /** \brief returns a pointer to the datastore used by this object */
651  inline JKQTPDatastore* getDatastore() { return plotter->getDatastore(); }
652 
653  /** \brief tells the plotter object to use the given external datastore.
654  *
655  * If the current datastore is internally managed, this method will free that object and use the supplied datastore
656  * with external management. If the current datastore is already external, this method will simply replace it by the
657  * new one.
658  */
659  inline void useExternalDatastore(JKQTPDatastore* newStore) { plotter->useExternalDatastore(newStore); }
660 
661  /** \copydoc JKQTBasePlotter::useAsInternalDatastore() */
662  inline void useAsInternalDatastore(JKQTPDatastore* newStore) { plotter->useAsInternalDatastore(newStore); }
663 
664  /** \copydoc JKQTBasePlotter::useInternalDatastore() */
665  inline void useInternalDatastore() { plotter->useInternalDatastore(); }
666 
667  /** \copydoc JKQTBasePlotter::forceInternalDatastore() */
668  inline void forceInternalDatastore() { plotter->forceInternalDatastore(); }
669 
670  /** \copydoc JKQTBasePlotter::setEmittingSignalsEnabled() */
671  inline void setEmittingSignalsEnabled(bool sig) { plotter->setEmittingSignalsEnabled(sig); }
672  /** \copydoc JKQTBasePlotter::isEmittingSignalsEnabled() */
673  inline bool isEmittingSignalsEnabled() { return plotter->isEmittingSignalsEnabled(); }
674 
675  /** \brief returns, whether automatic redrawing the plot is currently activated (e.g. you can deactivate this with setPlotUpdateEnabled() while performing major updates on the plot)
676  *
677  * \see setPlotUpdateEnabled()
678  */
679  bool isPlotUpdateEnabled() const;
680  /** \brief sets whether automatic redrawing the plot is currently activated (e.g. you can sett his to \c false while performing major updates on the plot)
681  *
682  * \see isPlotUpdateEnabled()
683  */
684  void setPlotUpdateEnabled(bool enable);
685 
686  /** \brief registeres a certain mouse drag action \a action to be executed when a mouse drag operation is
687  * initialized with the given \a button and \a modifier */
688  void registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action);
689  /** \brief deregisteres the mouse drag action to be executed when a mouse drag operation is
690  * initialized with the given \a button and \a modifier */
691  void deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier);
692  /** \brief clear all registeres mouse drag actions */
693  void clearAllRegisteredMouseDragActions();
694 
695  /** \brief registeres a certain mouse action \a action to be executed when a mouse double-click occurs
696  * with the given \a button and \a modifier */
697  void registerMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDoubleClickActions action);
698  /** \brief deregisteres the mouse action \a action to be executed when a mouse double-click occurs
699  * with the given \a button and \a modifier */
700  void deregisterMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier);
701  /** \brief clear all registered mouse double-click actions */
702  void clearAllRegisteredMouseDoubleClickActions();
703 
704  /** \brief specifies the action to perform on a mouse wheel event when a given modifier is pressed \see deregisterMouseWheelAction(), clearAllMouseWheelActions(), \ref JKQTPLOTTER_USERMOUSEINTERACTION */
705  void registerMouseWheelAction(Qt::KeyboardModifiers modifier, JKQTPMouseWheelActions action);
706  /** \brief deletes all mouse-wheel actions registered for a given \a modifier \see registerMouseWheelAction(), clearAllMouseWheelActions(), \ref JKQTPLOTTER_USERMOUSEINTERACTION */
707  void deregisterMouseWheelAction(Qt::KeyboardModifiers modifier);
708  /** \brief deletes all mouse-wheel actions \see registerMouseWheelAction(), deregisterMouseWheelAction(), \ref JKQTPLOTTER_USERMOUSEINTERACTION */
709  void clearAllMouseWheelActions();
710 
711  /*! \brief returns the currently set special context menu object
712  *
713  * \see \ref JKQTPLOTTER_SPECIALCONTEXTMENU, setSpecialContextMenu(), menuSpecialContextMenu, contextMenuOpened(), \ref JKQTPlotterUserInteraction
714  */
715  QMenu *getSpecialContextMenu() const;
716 
717  /*! \brief sets a QMenu object to be used as special context menu
718  *
719  * \see \ref JKQTPLOTTER_SPECIALCONTEXTMENU, getSpecialContextMenu(), menuSpecialContextMenu, contextMenuOpened()
720  */
721  void setSpecialContextMenu(QMenu* menu);
722 
723 
724  /** \brief x-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle)
725  *
726  * \see \ref JKQTPLOTTER_CONTEXTMENU , getMouseContextY(), getMouseLastClickX(), getMouseLastClickY()
727  */
728  double getMouseContextX() const;
729  /** \brief y-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle)
730  *
731  * \see \ref JKQTPLOTTER_CONTEXTMENU , getMouseContextX(), getMouseLastClickX(), getMouseLastClickY()
732  */
733  double getMouseContextY() const;
734  /** \brief x-position of the last mouse-click (in screen pixels)
735  *
736  * \see getMouseLastClickY(), getMouseContextX(), getMouseContextY()
737  */
738  int getMouseLastClickX() const;
739  /** \brief y-position of the last mouse-click (in screen pixels)
740  *
741  * \see getMouseLastClickX(), getMouseContextX(), getMouseContextY()
742  */
743  int getMouseLastClickY() const;
744 
745  /** \brief returns the coordinate axis object for the x-axis \see JKQTBasePlotter::getXAxis() */
746  inline JKQTPHorizontalAxis* getXAxis() { return plotter->getXAxis(); }
747  /** \brief returns the coordinate axis object for the y-axis \see JKQTBasePlotter::getYAxis() */
748  inline JKQTPVerticalAxis* getYAxis() { return plotter->getYAxis(); }
749  /** \brief returns the coordinate axis object for the x-axis as a const pointer \see JKQTBasePlotter::getXAxis() */
750  inline const JKQTPHorizontalAxis* getXAxis() const { return plotter->getXAxis(); }
751  /** \brief returns the coordinate axis object for the y-axis as a const pointer \see JKQTBasePlotter::getYAxis() */
752  inline const JKQTPVerticalAxis* getYAxis() const { return plotter->getYAxis(); }
753 
754  /** \brief returns the \a i -th graph (of type JKQTPPlotElement) in this plotter instance \see JKQTBasePlotter::getGraph() */
755  inline JKQTPPlotElement* getGraph(size_t i) { return plotter->getGraph(i); }
756 
757  /** \brief returns the number of graphs \see JKQTBasePlotter::getGraphCount() */
758  inline size_t getGraphCount() { return plotter->getGraphCount(); }
759 
760  /** \brief remove the i-th graph \see JKQTBasePlotter::deleteGraph() */
761  inline void deleteGraph(size_t i, bool deletegraph=true) { plotter->deleteGraph(i, deletegraph); }
762 
763  /** \brief returns \c true, if the given graph is present \see JKQTBasePlotter::containsGraph() */
764  inline bool containsGraph(JKQTPPlotElement* gr) { return plotter->containsGraph(gr); }
765 
766  /** \brief remove the given graph, if it is contained \see JKQTBasePlotter::deleteGraph() */
767  inline void deleteGraph(JKQTPPlotElement* gr, bool deletegraph=true) { plotter->deleteGraph(gr, deletegraph); }
768 
769  /** \brief remove all plots
770  *
771  * \param deleteGraphs if set \c true (default) the graph objects will also be deleted
772  *
773  * \see JKQTBasePlotter::clearGraphs()
774  */
775  inline void clearGraphs(bool deleteGraphs=true) { plotter->clearGraphs(deleteGraphs); }
776 
777  /** \brief add a new graph, returns it's position in the graphs list
778  *
779  * \param gr graph object (of type JKQTPPlotElement) to be added. \b Note: The JKQTPlotter takes ownership of graph \a gr .
780  * \return ID of the added graph object \a gr in the internal list of graphs
781  *
782  * \see JKQTBasePlotter::addGraph()
783  */
784  inline size_t addGraph(JKQTPPlotElement* gr) { return plotter->addGraph(gr); }
785 
786  /** \brief move the given graph to the top, or add it, if it is not yet contained
787  *
788  * \param gr graph object (of type JKQTPPlotElement) to be moved (needs to be containing to the JKQTPlotter already!)
789  * \return ID of the added graph object \a gr in the internal list of graphs
790  *
791  * \see JKQTBasePlotter::moveGraphTop()
792  */
793  inline size_t moveGraphTop(JKQTPPlotElement* gr) { return plotter->moveGraphTop(gr); }
794 
795  /** \brief move the given graph to the top, or add it, if it is not yet contained
796  *
797  * \param gr graph object (of type JKQTPPlotElement) to be moved (needs to be containing to the JKQTPlotter already!)
798  * \return ID of the added graph object \a gr in the internal list of graphs
799  *
800  * \see JKQTBasePlotter::moveGraphBottom()
801  */
802  inline size_t moveGraphBottom(JKQTPPlotElement* gr) { return plotter->moveGraphBottom(gr); }
803 
804  /** \brief add a new graphs from a QVector<JKQTPPlotElement*>, QList<JKQTPPlotElement*>, std::vector<JKQTPPlotElement*> ... or any standard-iterateable container with JKQTPPlotElement*-items
805  *
806  * \tparam TJKQTPGraphContainer a container type with default C++-sytle iterator interface
807  * (i.e. methods \c begin() and \c end() and an iterator, which may be
808  * moved to the next element with the operator \c ++ .
809  * \param gr Container of type TJKQTPGraphContainer, which contains the graphs \b Note: The JKQTPlotter takes ownership of graphs in \a gr .
810  * \param[out] graphIDsOut optional output parameter, the vector will contain the IDs of each graph added to theis plot
811  *
812  * \see JKQTBasePlotter::addGraphs()
813  */
814  template <class TJKQTPGraphContainer>
815  inline void addGraphs(const TJKQTPGraphContainer& gr, QVector<size_t>* graphIDsOut=nullptr) { plotter->addGraphs(gr, graphIDsOut); }
816 
817 
818  /** \brief returns the current x-axis min \see JKQTBasePlotter::getYAxis() */
819  inline double getXMin() const {return plotter->getXMin(); }
820 
821  /** \brief returns the current x-axis max \see JKQTBasePlotter::getYAxis() */
822  inline double getXMax() const {return plotter->getXMax(); }
823 
824  /** \brief returns the current y-axis min \see JKQTBasePlotter::getYAxis() */
825  inline double getYMin() const {return plotter->getYMin(); }
826 
827  /** \brief returns the current y-axis max \see JKQTBasePlotter::getYAxis() */
828  inline double getYMax() const {return plotter->getYMax(); }
829 
830 
831 
832  /** \brief returns the absolute x-axis min */
833  inline double getAbsoluteXMin() const {return plotter->getAbsoluteXMin(); }
834  /** \brief returns the absolute x-axis max */
835  inline double getAbsoluteXMax() const {return plotter->getAbsoluteXMax(); }
836 
837  /** \brief returns the absolute y-axis min */
838  inline double getAbsoluteYMin() const {return plotter->getAbsoluteYMin(); }
839 
840  /** \brief returns the absolute y-axis max */
841  inline double getAbsoluteYMax() const {return plotter->getAbsoluteYMax(); }
842 
843  /** \brief returns the current magnification factor */
844  inline double getMagnification() const { return magnification; }
845 
846  /** \brief gets the next unused style id, i.e. the smalles number >=0 which is not contained in usedStyles */
847  inline int getNextStyle() {
848  return getPlotter()->getNextStyle();
849  }
850 
851  /** \brief returns a QPen object for the i-th plot style */
853  return getConstplotter()->getPlotStyle(i);
854  }
855 
856 
857  /** \brief font size for key labels [in points] */
858  inline double getKeyFontSize() const {
859  return getConstplotter()->getKeyFontSize();
860  }
861 
862  /** \brief returns the currently set mode for the context menu \see JKQTPContextMenuModes, \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_SPECIALCONTEXTMENU , \ref JKQTPLOTTER_USERMOUSEINTERACTION */
863  JKQTPContextMenuModes getContextMenuMode() const;
864 
865  /** \brief current style properties for this JKQTPlotter
866  *
867  * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), \ref jkqtpplotter_styling
868  */
869  const JKQTPlotterStyle& getCurrentPlotterStyle() const;
870 
871  /** \brief replace the current style properties for this JKQTBasePlotter
872  *
873  * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
874  */
875  void setCurrentPlotterStyle(const JKQTPlotterStyle& style);
876  /** \brief replace the current style properties for this JKQTBasePlotter
877  *
878  * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
879  */
880  void setCurrentPlotterStyle(const JKQTPlotterStyle& style, const JKQTBasePlotterStyle &baseStyle);
881  /** \brief replace the current style properties for this JKQTBasePlotter with properties loaded from \a settings
882  *
883  * \param settings the QSettings object to read from
884  * \param group group in \a settings to read from
885  * \param alsoLoadBaseStyle if \c true, then also JKQTBasePlotter::loadCurrentPlotterStyle() of the internal JKQTBasePlotter is called
886  *
887  * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
888  */
889  void loadCurrentPlotterStyle(const QSettings& settings, const QString& group="plot/", bool alsoLoadBaseStyle=true);
890  /** \brief store the current style properties for this JKQTBasePlotter with properties loaded from \a settings
891  *
892  * \param settings the QSettings object to write to
893  * \param group group in \a settings to write to
894  * \param alsoSaveBaseStyle if \c true, then also JKQTBasePlotter::saveCurrentPlotterStyle() of the internal JKQTBasePlotter is called
895  *
896  * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
897  */
898  void saveCurrentPlotterStyle(QSettings& settings, const QString& group="plot/", bool alsoSaveBaseStyle=true) const;
899 
900  /** \brief \copydoc actMouseLeftAsToolTip */
901  QAction *getActMouseLeftAsToolTip() const;
902  /** \brief \copydoc actMouseLeftAsRuler */
903  QAction *getActMouseLeftAsRuler() const;
904  /** \brief \copydoc actMouseLeftAsDefault */
905  QAction *getActMouseLeftAsDefault() const;
906  /** \brief \copydoc actMouseLeftAsZoomRect */
907  QAction *getActMouseLeftAsZoomRect() const;
908  /** \brief \copydoc actMouseLeftAsPanView */
909  QAction *getActMouseLeftAsPanView() const;
910 
911 
912  public slots:
913  /** \brief set the current plot magnification */
914  void setMagnification(double m);
915  /** \brief sets x/ymin and x/ymax to the supplied values and replots the graph (zoom operation!) */
916  inline void zoom(double nxmin, double nxmax, double nymin, double nymax) {
917  plotter->zoom(nxmin, nxmax, nymin, nymax);
918  }
919 
920  /** \brief sets whether to plot grid lines or not
921  *
922  * \image html jkqtplotter_gridvisible.png "Grid visible"
923  * \image html jkqtplotter_gridinvisible.png "Grid invisible"
924  * */
925  inline void setGrid(bool val) {
926  plotter->setGrid(val);
927  }
928 
929  /** \brief sets the color of all Major grid lines
930  * */
931  inline void setGridColor(QColor color) {
932  plotter->setGridColor(color);
933  }
934 
935  /** \brief sets the color of all minor grid lines
936  * */
937  inline void setMinorGridColor(QColor color) {
938  plotter->setMinorGridColor(color);
939  }
940 
941  /** \brief sets the width of all Major grid lines
942  * */
943  inline void setGridWidth(double __value) {
944  plotter->setGridWidth(__value);
945  }
946 
947  /** \brief sets the width of all minor grid lines
948  * */
949  inline void setMinorGridWidth(double __value) {
950  plotter->setMinorGridWidth(__value);
951  }
952 
953  /** \brief sets the style of all Major grid lines
954  * */
955  inline void setGridStyle(Qt::PenStyle __value) {
956  plotter->setGridStyle(__value);
957  }
958 
959  /** \brief sets the style of all minor grid lines
960  * */
961  inline void setMinorGridStyle(Qt::PenStyle __value) {
962  plotter->setMinorGridStyle(__value);
963  }
964 
965  /** \brief switches the visibility of the zero-axes associated with the x- and y-axis
966  *
967  * \param showX indicates whether to show the zero-axis associated with the x-axis (i.e. x==0 or the vertical zero-axis)
968  * \param showY indicates whether to show the zero-axis associated with the y-axis (i.e. y==0 or the horizontal zero-axis)
969  * */
970  inline void setShowZeroAxes(bool showX, bool showY) {
971  plotter->setShowZeroAxes(showX, showY);
972  }
973  /** \brief switches the visibility of the zero-axes associated with the x- and y-axis
974  *
975  * \param showXY indicates whether to show the zero-axis associated with the x- and y-axis
976  * */
977  inline void setShowZeroAxes(bool showXY) {
978  plotter->setShowZeroAxes(showXY);
979  }
980 
981  /** \brief save the current plot as an image file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed.
982  * The image format is extracted from the file extension (jpeg, tiff, png, pdf, ...) */
983  inline void saveImage(const QString& filename=QString(""), bool displayPreview=true) {
984  plotter->saveImage(filename, displayPreview);
985  }
986 
987  /** \brief save the data used for the current plot. The file format is extracted from the file extension (csv, ...)
988  *
989  * The parameter \a format specifies the export format. if it is empty the format will be choosen according to the file extension, or
990  * if \a filename is also empty the format will be choosen according to what is selected in the file selection dialog.
991  *
992  * If \a format is \c "slk" the output will be in SYLK format, if \a format is \c "csv" or \a "dat" the output will be comma separated values
993  * and if \a format is \c "txt" the output will be tab separated values.
994  */
995  inline void saveData(const QString& filename=QString(""), const QString& format=QString("")) {
996  plotter->saveData(filename, format);
997  }
998 
999  /** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed */
1000  inline void print(QPrinter* printer=nullptr) {
1001  plotter->print(printer);
1002  }
1003 
1004  /** \brief copy displayed data to cpliboard */
1005  inline void copyData() {
1006  plotter->copyData();
1007  }
1008 
1009  /** \brief copy displayed data to cpliboard in Matlab syntax */
1010  inline void copyDataMatlab() {
1011  plotter->copyDataMatlab();
1012  }
1013  /** \brief this method zooms the graph so that all plotted datapoints are visible.
1014  *
1015  * \param zoomX if set \c true (default) zooms the x axis
1016  * \param zoomY if set \c true (default) zooms the y axis
1017  * \param includeX0 if this is \c true zoomToFit() will ensure that \f$ x=0 \f$ is visible in the plot (only for non-logx plots, default: false)
1018  * \param includeY0 if this is \c true zoomToFit() will ensure that \f$ y=0 \f$ is visible in the plot (only for non-logy plots, default: false)
1019  * \param scaleX the plot will have a width of \f$ \mbox{Xscale}\cdot\Delta x \f$ where \f$ \Delta x \f$ is the actual x-axis data range
1020  * For logx plots we actually use this on the logarithmized data! (default: 1.05)
1021  * \param scaleY the plot will have a height of \f$ \mbox{Yscale}\cdot\Delta < \f$ where \f$ \Delta < \f$ is the actual <-axis data range
1022  * For log< plots we actually use this on the logarithmized data! (default: 1.05)
1023  *
1024  */
1025  inline void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05) {
1026  plotter->zoomToFit(zoomX, zoomY, includeX0, includeY0, scaleX, scaleY);
1027  }
1028 
1029  /** \brief zooms into the graph (the same as turning the mouse wheel) by the given factor */
1030  inline void zoomIn(double factor=2.0) { plotter->zoomIn(factor); }
1031  /** \brief zooms out of the graph (the same as turning the mouse wheel) by the given factor */
1032  inline void zoomOut(double factor=2.0) { plotter->zoomOut(factor); }
1033 
1034  /** \brief update the plot and the overlays */
1035  void redrawPlot();
1036 
1037  /** \brief replot overlays only (use redrawPlot() to replot the plot and the overlays)
1038  *
1039  * You can use this function, if you only changed the overlays but not the graphs in this plotter.
1040  * Then only the overlas are redrawn and the old (saved) image of the graphs and the coordinate syste,
1041  * is used as a base. This is significantly faster than redrawing the whole plot.
1042  */
1043  void redrawOverlays();
1044 
1045  /** \brief allows to activate/deactivate toolbar buttons that can activate certain mouse drag actions
1046  *
1047  * \see getActMouseLeftAsDefault(), getActMouseLeftAsRuler(), getActMouseLeftAsToolTip()
1048  */
1049  void setMouseActionToolbarActionsActive(bool __value);
1050 
1051  /** \brief returns whether the toolbar is enabled
1052  *
1053  * \copydetails JKQTPlotterStyle::toolbarEnabled
1054  *
1055  * \see isToolbarEnabled(), JKQTPlotterStyle::toolbarEnabled
1056  */
1057  void setToolbarEnabled(bool __value);
1058  /** \brief returns whether the toolbar is always visible or only when the mouse moves to the upper left area
1059  *
1060  * \copydetails JKQTPlotterStyle::toolbarAlwaysOn
1061  *
1062  * \see isToolbarAlwaysOn(), JKQTPlotterStyle::toolbarAlwaysOn
1063  */
1064  void setToolbarAlwaysOn(bool __value);
1065  /** \brief specifies whether to display the current position of the mouse in the top border of the plot (this may automatically extent the
1066  * top border, so the position fits in. The default widget font is used for the output.
1067  *
1068  * \copydetails JKQTPlotterStyle::displayMousePosition
1069  *
1070  * \see isMousePositionShown(), JKQTPlotterStyle::displayMousePosition, \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEMOVE */
1071  void setMousePositionShown(bool __value);
1072  /** \copydoc JKQTPlotterStyle::userActionOverlayPen
1073  *
1074  * \see setUserActionOverlayPen(), getUserActionOverlayPen(), JKQTPlotterStyle::userActionOverlayPen \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
1075  void setUserActionOverlayPen(const QPen & __value);
1076  /** \copydoc JKQTPlotterStyle::userActionOverlayPen
1077  *
1078  * \see setUserActionOverlayBrush(), getUserActionOverlayBrush(), JKQTPlotterStyle::userActionOverlayBrush \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
1079  void setUserActionOverlayBrush(const QBrush & __value);
1080  /** \copydoc JKQTPlotterStyle::userActionOpaquePen
1081  *
1082  * \see setUserActionOpaquePen(), getUserActionOpaquePen(), JKQTPlotterStyle::userActionOpaquePen \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
1083  void setUserActionOpaquePen(const QPen & __value);
1084  /** \copydoc JKQTPlotterStyle::userActionOpaquePen
1085  *
1086  * \see setUserActionOpaqueBrush(), getUserActionOpaqueBrush(), JKQTPlotterStyle::userActionOpaqueBrush \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
1087  void setUserActionOpaqueBrush(const QBrush & __value);
1088  /** \copydoc JKQTPlotterStyle::userActionMarkerPen
1089  *
1090  * \see setUserActionMarkerPen(), getUserActionMarkerPen(), JKQTPlotterStyle::userActionMarkerPen \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
1091  void setUserActionMarkerPen(const QPen & __value);
1092  /** \copydoc JKQTPlotterStyle::userActionMarkerPen
1093  *
1094  * \see setUserActionMarkerBrush(), getUserActionMarkerBrush(), JKQTPlotterStyle::userActionMarkerBrush \ref JKQTPLOTTER_USERMOUSEINTERACTION_MOUSEDRAG */
1095  void setUserActionMarkerBrush(const QBrush & __value);
1096 
1097  /** \copydoc JKQTPlotterStyle::maxTooltipDistance */
1098  void setMaxTooltipDistance(int v);
1099 
1100  /** \copydoc JKQTPlotterStyle::userActionCatchSensitivity */
1101  void setUserActionCatchSensitivity(int v);
1102 
1103  /** \copydoc JKQTPlotterStyle::userActionMarkerDiameter */
1104  void setUserActionMarkerDiameter(int v);
1105 
1106  /** \copydoc JKQTPlotterStyle::userActionMarkerType */
1107  void setUserActionMarkerType(JKQTPUserActionMarkerType v);
1108 
1109  /** \brief sets the mode if the standard context menu \see JKQTPContextMenuModes, \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_SPECIALCONTEXTMENU , \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1110  void setContextMenuMode(JKQTPContextMenuModes mode);
1111 
1112  /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT */
1113  void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender);
1114  /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local y-axis to the other y-axis \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT */
1115  void synchronizeYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender);
1116  /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x- and y-axis to the other x- and y-axis \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT */
1117  void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender);
1118 
1119 
1120  /** \brief popuplate the given toolbar \a toolbar with all actions shown in a toolbar from this class ...
1121  *
1122  * This function can be used to populate an external toolbar with actions for this JKQTPlotter.
1123  */
1124  void populateToolbar(QToolBar* toolbar) const;
1125 
1126  /** \brief open the context menu at the mouse position of the last click \see \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1127  void openContextMenu();
1128  /** \brief open the context menu at the mouse position \a x and \a y \see \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1129  void openContextMenu(int x, int y);
1130 
1131  /** \brief open the standard context menu at the mouse position of the last click \see \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1132  void openStandardContextMenu();
1133  /** \brief open the standard context menu at the mouse position \a x and \a y \see \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1134  void openStandardContextMenu(int x, int y);
1135  /** \brief open the special context menu at the mouse position of the last click \see \ref JKQTPLOTTER_SPECIALCONTEXTMENU, \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1136  void openSpecialContextMenu();
1137  /** \brief open the special context menu at the mouse position \a x and \a y \see \ref JKQTPLOTTER_SPECIALCONTEXTMENU, \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1138  void openSpecialContextMenu(int x, int y);
1139 
1140  /** \brief open the standard context menu with the special context menu integrated at the mouse position of the last click \see \ref JKQTPLOTTER_SPECIALCONTEXTMENU, \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1141  void openStandardAndSpecialContextMenu();
1142  /** \brief open the standard context menu with the special context menu integrated at the mouse position \a x and \a y \see \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_SPECIALCONTEXTMENU, \ref JKQTPLOTTER_USERMOUSEINTERACTION */
1143  void openStandardAndSpecialContextMenu(int x, int y);
1144 
1145  /** \brief sets absolutely limiting x-range of the plot
1146  *
1147  * \param xminn absolute minimum of x-axis
1148  * \param xmaxx absolute maximum of x-axis
1149  *
1150  * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents!
1151  *
1152  * \see setAbsoluteXY(), setAbsoluteY(), JKQTBasePlotter::setAbsoluteX()
1153  */
1154  inline void setAbsoluteX(double xminn, double xmaxx) { plotter->setAbsoluteX(xminn, xmaxx); }
1155 
1156  /** \brief sets absolute minimum and maximum y-value to plot
1157  *
1158  * \param yminn absolute minimum of y-axis
1159  * \param ymaxx absolute maximum of y-axis
1160  *
1161  * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents!
1162  *
1163  * \see setAbsoluteXY(), setAbsoluteX(), JKQTBasePlotter::setAbsoluteY()
1164  */
1165  inline void setAbsoluteY(double yminn, double ymaxx) { plotter->setAbsoluteY(yminn, ymaxx); }
1166 
1167  /** \brief sets absolutely limiting x- and y-range of the plot
1168  *
1169  * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function.
1170  *
1171  * \param xminn absolute minimum of x-axis
1172  * \param xmaxx absolute maximum of x-axis
1173  * \param yminn absolute minimum of y-axis
1174  * \param ymaxx absolute maximum of y-axis
1175  *
1176  * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents!
1177  *
1178  * \see setAbsoluteX(), setAbsoluteY(), zoomToFit(), JKQTBasePlotter::setAbsoluteXY()
1179  */
1180  inline void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx) { plotter->setAbsoluteXY(xminn, xmaxx, yminn, ymaxx); }
1181 
1182  /** \brief sets the x-range of the plot (minimum and maximum x-value on the x-axis)
1183  *
1184  * \param xminn absolute minimum of x-axis
1185  * \param xmaxx absolute maximum of x-axis
1186  *
1187  * \note You cannot expand the x-range outside the absolute x-range set e.g. by setAbsoluteX()!
1188  * Also the range will be limited to possible values (e.g. to positive values if you use
1189  * logarithmic axes).
1190  *
1191  * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals
1192  * is activated at the moment (e.g. using JKQTBasePlotter::setEmittingSignalsEnabled() ).
1193  *
1194  * \see setY(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTBasePlotter::setY()
1195  */
1196  inline void setX(double xminn, double xmaxx) { plotter->setX(xminn, xmaxx); }
1197 
1198  /** \brief sets the y-range of the plot (minimum and maximum y-value on the y-axis)
1199  *
1200  * \param yminn absolute minimum of y-axis
1201  * \param ymaxx absolute maximum of y-axis
1202  *
1203  * \note You cannot expand the y-range outside the absolute y-range set e.g. by setAbsoluteY()!
1204  * Also the range will be limited to possible values (e.g. to positive values if you use
1205  * logarithmic axes).
1206  *
1207  * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals
1208  * is activated at the moment (e.g. using JKQTBasePlotter::setEmittingSignalsEnabled() ).
1209  *
1210  * \see setX(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTBasePlotter::setX()
1211  */
1212  inline void setY(double yminn, double ymaxx) { plotter->setY(yminn, ymaxx); }
1213 
1214  /** \brief sets the x- and y-range of the plot (minimum and maximum values on the x-/y-axis)
1215  *
1216  * \param xminn absolute minimum of x-axis
1217  * \param xmaxx absolute maximum of x-axis
1218  * \param yminn absolute minimum of y-axis
1219  * \param ymaxx absolute maximum of y-axis
1220  *
1221  * \note You cannot expand the ranges outside the absolute ranges set e.g. by setAbsoluteXY()!
1222  * Also the range will be limited to possible values (e.g. to positive values if you use
1223  * logarithmic axes).
1224  *
1225  * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals
1226  * is activated at the moment (e.g. using JKQTBasePlotter::setEmittingSignalsEnabled() ).
1227  *
1228  * \see setX(), setX(), zoomToFit(), setAbsoluteXY(), JKQTBasePlotter::setXY()
1229  */
1230  inline void setXY(double xminn, double xmaxx, double yminn, double ymaxx) { plotter->setXY(xminn, xmaxx, yminn, ymaxx); }
1231 
1232  signals:
1233  /** \brief emitted whenever the mouse moves
1234  *
1235  * \param x x-position of the mouse (in plot coordinates)
1236  * \param y y-position of the mouse (in plot coordinates)
1237  */
1238  void plotMouseMove(double x, double y);
1239  /** \brief emitted when a single-click event from the mouse occurs inside the plot
1240  *
1241  * \param x x-position of the mouse (in plot coordinates)
1242  * \param y y-position of the mouse (in plot coordinates)
1243  * \param modifiers key-modifiers when the click occured
1244  * \param button mouse-button that was used for the click
1245  */
1246  void plotMouseClicked(double x, double y, Qt::KeyboardModifiers modifiers, Qt::MouseButton button);
1247  /** \brief emitted when a double-click event from the mouse occurs inside the plot
1248  *
1249  * \param x x-position of the mouse (in plot coordinates)
1250  * \param y y-position of the mouse (in plot coordinates)
1251  * \param modifiers key-modifiers when the click occured
1252  * \param button mouse-button that was used for the click
1253  */
1254  void plotMouseDoubleClicked(double x, double y, Qt::KeyboardModifiers modifiers, Qt::MouseButton button);
1255  /** \brief emitted when a single-click event from the mouse occurs inside the plot
1256  *
1257  * \param x x-position of the mouse (in plot coordinates)
1258  * \param y y-position of the mouse (in plot coordinates)
1259  * \param modifiers key-modifiers when the click occured
1260  * \param deltaAngleX amount of rotation (in eighths of a degree) of the wheel in x-direction
1261  * \param deltaAngleY amount of rotation (in eighths of a degree) of the wheel in y-direction
1262  */
1263  void plotMouseWheelOperated(double x, double y, Qt::KeyboardModifiers modifiers, int deltaAngleX, int deltaAngleY);
1264  /** \brief emitted when the mouse action jkqtpmdaZoomByRectangle and the drawing of the new zoom rectangle is finished (=mouse key released)
1265  *
1266  * \param mouseDragRectXStart start of the selected x-range (in plot coordinates)
1267  * \param mouseDragRectXEnd end of the selected x-range (in plot coordinates)
1268  * \param mouseDragRectYStart start of the selected x-range (in plot coordinates)
1269  * \param mouseDragRectYEnd end of the selected x-range (in plot coordinates)
1270  * \param modifiers key-modifiers when the click occured
1271  */
1272  void plotNewZoomRectangle(double mouseDragRectXStart, double mouseDragRectXEnd, double mouseDragRectYStart, double mouseDragRectYEnd, Qt::KeyboardModifiers modifiers);
1273  /** \brief emitted when the plot scaling has been recalculated */
1274  void plotScalingRecalculated();
1275  /** \brief emitted before the plot scaling has been recalculated */
1276  void beforePlotScalingRecalculate();
1277  /** \brief emitted whenever a context menu is opened. You can modify the menu via the parameter \a contextMenu!
1278  *
1279  * \param x x-position of the context-menu (in plot coordinates)
1280  * \param y y-position of the context-menu (in plot coordinates)
1281  * \param contextMenu QMenu-object of the context menu. This object may be altered to display additional items ... Here is an example:
1282  * \code
1283  * contextMenu->addSeparator();
1284  * QAction* act=contextMenu->addMenu(QString("contextMenuOpened(x=%1, y=%2)").arg(x).arg(y))->addAction("user-added action");
1285  * connect(act, &QAction::triggered, [x,y]() { QMessageBox::warning(nullptr, tr("Plot Context Menu"),
1286  * tr("Context Menu was opened at x/y=%1/%2!").arg(x).arg(y),
1287  * QMessageBox::Ok,
1288  * QMessageBox::Ok); });
1289  * \endcode
1290  * <b>Please read the warning below!!!</b>
1291  *
1292  * \warning A note of care: This signal can be used to alter the context menu. It behaves differently, depending on
1293  * whether you use the standard context menu, or the special context menu (setSpecialContextMenu()). If the
1294  * standard menu is opened, your alterations are valid until it is shown the next time (i.e. the internal
1295  * context menu object is deleted in between). If you show the special context menu only, your alterations
1296  * are <b>permanently stored</b> in the menu object. I.e. if you use the code example above and open the menu
1297  * several times, it will accumulate additional menu entries!
1298  * If you must modify the special menu, just access actions and do not add or delete any in a slot bound to
1299  * this signal! You can recognize the special menu with code like this:
1300  * \code
1301  * if (contextMenu == plot->getSpecialContextMenu()) {
1302  * //...
1303  * // do something with the special menu, do not add/remove entries
1304  * } else {
1305  * //...
1306  * // do something with the standard menu, you are free to do anything!
1307  * }
1308  * \endcode
1309  *
1310  * \see \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_SPECIALCONTEXTMENU, \ref JKQTPLOTTER_USERMOUSEINTERACTION
1311  */
1312  void contextMenuOpened(double x, double y, QMenu* contextMenu);
1313 
1314 
1315  /** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse)
1316  *
1317  * \param newxmin start of the selected x-range (in plot coordinates)
1318  * \param newxmax end of the selected x-range (in plot coordinates)
1319  * \param newymin start of the selected x-range (in plot coordinates)
1320  * \param newymax end of the selected x-range (in plot coordinates)
1321  * \param sender JKQTPlotter sending this event
1322  *
1323  * This signal is designed to be connected to these slots: synchronizeXAxis(), synchronizeYAxis(), synchronizeXYAxis()
1324  */
1325  void zoomChangedLocally(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender);
1326 
1327  /** \brief emitted when the mouse action JKQTPlotter::ScribbleEvents and a click event from the mouse occurs inside the plot,
1328  * or the mouse moved while the left button is pressed down
1329  *
1330  * \param x x-position of the mouse (in plot coordinates)
1331  * \param y y-position of the mouse (in plot coordinates)
1332  * \param modifiers key-modifiers when the event was generated
1333  * \param first if \c true: this is the first event of a series that starts with pressing the mouse-button down, within the series, this is \c false
1334  * \param last if \c true: this is the last event of a series that ends when releasing the mouse-button, within the series, this is \c false
1335  */
1336  void userScribbleClick(double x, double y, Qt::KeyboardModifiers modifiers, bool first, bool last);
1337  /** \brief emitted when the mouse action JKQTPlotter::RectangleEvents and the drawing of the new rectangle is finished (=mouse key released)
1338  *
1339  * \param x x-coordinate of the bottom left corner of the rectangle (in plot coordinates)
1340  * \param y y-coordinate of the bottom left corner of the rectangle (in plot coordinates)
1341  * \param width width of the rectangle (in plot coordinates)
1342  * \param height height of the rectangle (in plot coordinates)
1343  * \param modifiers key-modifiers when the rectangle was finished
1344  */
1345  void userRectangleFinished(double x, double y, double width, double height, Qt::KeyboardModifiers modifiers);
1346  /** \brief emitted when the mouse action JKQTPlotter::LineEvents and the drawing of the new line is finished (=mouse key released)
1347  *
1348  * \param x1 x-coordinate of the start of the line (in plot coordinates)
1349  * \param y1 y-coordinate of the start of the line (in plot coordinates)
1350  * \param x2 x-coordinate of the end of the line (in plot coordinates)
1351  * \param y2 y-coordinate of the end of the line (in plot coordinates)
1352  * \param modifiers key-modifiers when the rectangle was finished
1353  */
1354  void userLineFinished(double x1, double y1, double x2, double y2, Qt::KeyboardModifiers modifiers);
1355  /** \brief emitted when the mouse action JKQTPlotter::CircleEvents and the drawing of the new circle is finished (=mouse key released)
1356  *
1357  * \param x x-coordinate of the center of the circle (in plot coordinates)
1358  * \param y y-coordinate of the center of the circle (in plot coordinates)
1359  * \param radius radius of the circle (in plot coordinates)
1360  * \param modifiers key-modifiers when the rectangle was finished
1361  */
1362  void userCircleFinished(double x, double y, double radius, Qt::KeyboardModifiers modifiers);
1363  /** \brief emitted when the mouse action JKQTPlotter::EllipseEvents and the drawing of the new ellipse is finished (=mouse key released)
1364  *
1365  * \param x x-coordinate of the center of the ellipse (in plot coordinates)
1366  * \param y y-coordinate of the center of the ellipse (in plot coordinates)
1367  * \param radiusX half-axis in x-direction of the ellipse (in plot coordinates)
1368  * \param radiusY half-axis in y-direction of the ellipse (in plot coordinates)
1369  * \param modifiers key-modifiers when the rectangle was finished
1370  */
1371  void userEllipseFinished(double x, double y, double radiusX, double radiusY, Qt::KeyboardModifiers modifiers);
1372  /** \brief emitted when a tooltip for a datapoint is displayed
1373  *
1374  * \param x x-coordinate of the center of the marked datapoint (in plot coordinates)
1375  * \param y y-coordinate of the center of the marked datapoint (in plot coordinates)
1376  * \param entries contents of the tooltip
1377  * \param graphs graph objects that created the entries
1378  */
1379  void tooltipDisplayed(double x, double y, const QStringList& entries, const QList<JKQTPPlotElement*>& graphs);
1380  /** \brief emitted when a new ruler between two points is displayed
1381  *
1382  * \param x1 x-coordinate of the start of the line (in plot coordinates)
1383  * \param y1 y-coordinate of the start of the line (in plot coordinates)
1384  * \param x2 x-coordinate of the end of the line (in plot coordinates)
1385  * \param y2 y-coordinate of the end of the line (in plot coordinates)
1386  * \param modifiers key-modifiers when the rectangle was finished
1387  */
1388  void rulerDisplayed(double x1, double y1, double x2, double y2, Qt::KeyboardModifiers modifiers);
1389 
1390 
1391  protected:
1392 
1393  /** \brief ties a MouseActionMode to a mouse-button and a keyboard-modifier
1394  * \internal
1395  * \ingroup jkqtpplottersupprt
1396  */
1398  /** \brief constructs an invalid object */
1399  MouseDragAction();
1400  MouseDragAction(Qt::MouseButton _mouseButton, Qt::KeyboardModifiers _modifier, JKQTPMouseDragActions _mode);
1402  Qt::KeyboardModifiers modifier;
1403  Qt::MouseButton mouseButton;
1404  bool isValid() const;
1405  void clear();
1406  private:
1407  bool valid;
1408  };
1409 
1410  /** \brief the currently executed MouseDragAction */
1412 
1413  /** \brief searches JKQTPlotterStyle::registeredMouseActionModes for a matching action, returns in \a found whether an action was found */
1414  JKQTPMouseDragActionsHashMapIterator findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers, bool *found=nullptr) const;
1415 
1416  /** \brief searches JKQTPlotterStyle::registeredMouseWheelActions for a matching action */
1417  JKQTPMouseWheelActionsHashMapIterator findMatchingMouseWheelAction(Qt::KeyboardModifiers modifiers) const;
1418 
1419  /** \brief searches JKQTPlotterStyle::registeredMouseDoubleClickActions for a matching action */
1420  JKQTPMouseDoubleClickActionsHashMapIterator findMatchingMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const;
1421 
1422  /** \brief you may overwrite this method to modify the given context menu before it is displayed.
1423  *
1424  * The plotter will fill the menu with the default items and then call this method. The default implementation does NOTHING.
1425  *
1426  * \see \ref JKQTPLOTTER_CONTEXTMENU , \ref JKQTPLOTTER_USERMOUSEINTERACTION
1427  */
1428  void modifyContextMenu(QMenu* menu);
1429 
1430  /** \brief indicates whether the plot is updated automatically at the moment
1431  *
1432  * \see setPlotUpdateEnabled(), isPlotUpdateEnabled()
1433  */
1435 
1436  /** \brief JKQTBasePlotter used to plot */
1438 
1439  /** \brief modifies the settings of \a plotter to match those of this object */
1440  void fixBasePlotterSettings();
1441 
1442 
1443  /** \brief this is set \c true if we are drawing a zoom rectangle */
1445 
1446  /** \brief when draging the mouse this contains the x-coordinate the user clicked on (in plot coordinates) */
1448 
1449  /** \brief when draging the mouse this contains the x-coordinate the user clicked on (in pixels) */
1451 
1452  /** \brief when draging the mouse this contains the x-coordinate the mouse is currently
1453  * pointing to (in pixels) */
1455 
1456  /** \brief when draging the mouse this contains the y-coordinate the mouse is currently
1457  * pointing to (in pixels) */
1459 
1460  /** \brief when draging the mouse this contains the x-coordinate the mouse is currently
1461  * pointing to
1462  */
1464 
1465  /** \brief when draging the mouse this contains the y-coordinate the user clicked on (in plot coordinates) */
1467 
1468  /** \brief when zooming by moving the mouse this contains the y-coordinate the user clicked on (in pixels) */
1470 
1471  /** \brief when zooming by moving the mouse this contains the y-coordinate the mouse is currently
1472  * pointing to
1473  */
1475 
1476  /** \brief describes a marker to be drawn by paintUserAction() */
1478  inline MouseDragMarker(const QPoint& pos_, const QString& label_, const QString& title_, const QColor& color_, const QImage& keymarker_=QImage(), JKQTPPlotElement* _graph=nullptr):
1479  pos(pos_), label(label_), title(title_), color(color_), keyMarker(keymarker_), graph(_graph)
1480  {}
1481  /** \brief position of the marker in screen pixels */
1482  QPoint pos;
1483  /** \brief marker label */
1484  QString label;
1485  /** \brief graph label */
1486  QString title;
1487  /** \brief color for the marker */
1488  QColor color;
1489  /** \brief key marker image */
1490  QImage keyMarker;
1491  /** \brief graph that created that marker */
1493  };
1494  /** \brief internal list of markers to be drawn by paintUserAction() */
1495  QList<MouseDragMarker> mouseDragMarkers;
1496 
1497 
1498  /** \brief this stores the currently displayed plot */
1499  QImage image;
1500 
1501  /** \brief this stores the currently displayed plot */
1503 
1504  /** \brief this can be used when drawing a zoom rectangle to store an unchanged
1505  * copy of the currently displayed image.
1506  */
1507  QImage oldImage;
1508 
1509 
1510  /** \brief use this QMenu instance instead of the standard context menu of this widget
1511  * \see \ref JKQTPLOTTER_SPECIALCONTEXTMENU
1512  */
1514 
1515 
1516 
1517  /** \brief toolbar class used for user input */
1519 
1520 
1521  /** \brief paint the user action (rectangle, ellipse, ... */
1522  void paintUserAction();
1523 
1524 
1525  /** \brief event handler for a double click
1526  *
1527  * \see registerMouseDoubleClickAction(), deregisterMouseDoubleClickAction()
1528  */
1529  void mouseDoubleClickEvent ( QMouseEvent * event );
1530 
1531  /*! \brief react on key presses.
1532 
1533  These shortcuts are defined:
1534  - ESC stops current zooming/drawing action
1535  .
1536  */
1537  void keyReleaseEvent(QKeyEvent* event);
1538 
1539  /** \brief event handler for a mouse move
1540  *
1541  * This implements two behaviours:
1542  * - if displayMousePosition is \c true , stores the current mouse position in mousePosX, mousePosY
1543  * - if necessary, contributes to user-actions started by mousePressEvent()
1544  * - emits plotMouseMove() if the mouse is inside the plot rectangle .
1545  * .
1546  *
1547  * \see mousePosX, mousePosY
1548  */
1549  void mouseMoveEvent ( QMouseEvent * event );
1550 
1551  /** \brief event handler for a mouse down event
1552  *
1553  * This event determines the action to be performed from registeredMouseActionModes
1554  * and then sets currentMouseDragAction accordingly and starts the mouse action.
1555  *
1556  * \see registerMouseDragAction(), deregisterMouseDragAction(), registeredJKQTPMouseDragActions
1557  */
1558  void mousePressEvent ( QMouseEvent * event );
1559 
1560  /** \brief event handler for a mouse release event
1561  *
1562  * this finishes the action, started by mousePressEvent()
1563  */
1564  void mouseReleaseEvent ( QMouseEvent * event );
1565 
1566  /** \brief event handler for a turn of the mouse wheel
1567  *
1568  * Executes the user action defined for the mouse wheel.
1569  *
1570  * \see registerMouseWheelAction(), deregisterMouseWheelAction(), registeredMouseWheelActions
1571  */
1572  void wheelEvent(QWheelEvent * event);
1573 
1574  /** \brief this simply paints the stored image to the widget's surface */
1575  void paintEvent(QPaintEvent *event);
1576 
1577  /** \brief resizes the internal representation (image) of the graphs */
1578  void resizeEvent(QResizeEvent *event);
1579 
1580  /** \brief called, when the mouse leaves the widget, hides the toolbar (if visible) */
1581  void leaveEvent ( QEvent * event );
1582 
1583 
1584  /** \brief update settings of the toolbar */
1585  void updateToolbar();
1586 
1587 
1588  /** \brief the master plotter, this plotter is connected to in x-direction. */
1589  QPointer<JKQTPlotter> masterPlotterX;
1590  /** \brief the master plotter, this plotter is connected to in y-direction. */
1591  QPointer<JKQTPlotter> masterPlotterY;
1592 
1593  /** \brief calculate the y-axis shift of the plot, so there is space for the potentially displayed mouse position label */
1594  int getPlotYOffset();
1595 
1596  /** \brief x-position of the mouse during the last mouseMoveEvent() calls (in plot coordinates) */
1597  double mousePosX;
1598  /** \brief y-position of the mouse during the last mouseMoveEvent() calls (in plot coordinates) */
1599  double mousePosY;
1600  /** \brief magnification factor for the display of the plot */
1602  /** \brief current minimal size of the JKQTPlotter widget to properly display the plot */
1603  QSize minSize;
1604 
1605  /** \brief the context menu object used by this JKQTPlotter
1606  *
1607  * \note this might be \c ==nullptr occasionally, therefore you need to check it, before accessing it!
1608  *
1609  * \see \ref JKQTPLOTTER_CONTEXTMENU , resetContextMenu(), initContextMenu(), contextMenuMode
1610  */
1611  QMenu* contextMenu;
1612  /** \brief current mode for the default context menu (i.e. the right-click context menu) \see \ref JKQTPLOTTER_CONTEXTMENU */
1614  /** \brief x-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */
1616  /** \brief y-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */
1618  /** \brief x-position of the last mouse-click (in screen pixels) */
1620  /** \brief y-position of the last mouse-click (in screen pixels) */
1622  /** \brief internal storage for sub-menu entries of the internal contextMenu object, based on the actions returned by JKQTBasePlotter::getLstAdditionalPlotterActions()
1623  * \internal
1624  */
1625  QList<QMenu*> contextSubMenus;
1626  /** \brief fills the member contextMenu with all default and additionally registered actions, also calls modifyContextMenu()
1627  *
1628  * \note This function calls resetContextMenu() internally!
1629  *
1630  * \see resetContextMenu(), contextMenuMode
1631  */
1632  void initContextMenu();
1633  /** \brief set the current mouse cursor shappe according to currentMouseDragAction */
1634  void updateCursor();
1635 
1636  /** \brief current style properties for this JKQTPlotter
1637  *
1638  * \see JKQTPSetSystemDefaultStyle(), JKQTPSetSystemDefaultStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
1639  */
1641 
1642 
1643  /** \brief timer used while the graph is resized to delay the redrawing with new size (in the meantime, an intermediate graphic is displayed)
1644  * \internal
1645  * \see delayedResizeEvent()
1646  *
1647  * \image html jkqtplotter_fastresizing.gif
1648  */
1649  QTimer resizeTimer;
1650 
1651  /** \brief destroys the internal contextMenu and optionally creates a new one
1652  *
1653  * \param createnew if \c ==true, contextMenu is reinitialized with a (shiny) new QMenu,
1654  * otherwise it is set to \c nullptr after destroying the old menu.
1655  *
1656  * \see initContextMenu(), contextMenuMode
1657  */
1658  void resetContextMenu(bool createnew=true);
1659 
1660  /** \brief fills the inertnal mouseDragMarkers structure with data to display tooltips close to (x0, y0)
1661  *
1662  * if \a emitEvent is \c true, the signal is emitted before the function returns
1663  */
1664  void fillInternalStructForToolTipOfClosestDataPoint(double x0, double y0, bool emitEvent=true);
1665  /** \brief resets the currently activated mouse drag action, e.g. called by mouseReleaseEvent() */
1666  void resetCurrentMouseDragAction();
1667 
1668  /** \brief list of override mouse drag action modes, that override the settings ing plotterStyle.registeredMouseDragActionModes \see setOverrideMouseDragAction(), resetOverrideMouseDragAction(), JKQTPlotterStyle::registeredMouseDragActionModes */
1670 
1671  /** \brief sets an override mouse drag action for the given button/modifiers combination \see setOverrideMouseDragAction(), resetOverrideMouseDragAction(), registeredOverrideMouseDragActionModes */
1672  void setOverrideMouseDragAction(Qt::MouseButton button,Qt::KeyboardModifiers modifiers, JKQTPMouseDragActions action);
1673  /** \brief removes a previously set override mouse drag action for the given button/modifiers combination \see setOverrideMouseDragAction(), resetOverrideMouseDragAction(), registeredOverrideMouseDragActionModes */
1674  void resetOverrideMouseDragAction(Qt::MouseButton button,Qt::KeyboardModifiers modifiers);
1675 
1676  /** \brief action group, that groups the actMouseLeft... actions */
1677  QActionGroup* actgrpMouseLeft;
1678  /** \brief action that activates the default action, set in plotterStyle! */
1680  /** \brief action that activates the ruler tool (override!) */
1682  /** \brief action that activates the tooltip tool (override!) */
1684  /** \brief action that activates the zoom rectangle tool (override!) */
1686  /** \brief action that activates the pan view tool (override!) */
1688 
1689  protected slots:
1690  /** \brief while the window is resized, the plot is only redrawn after a restartable delay, implemented by this function and resizeTimer
1691  * \internal
1692  * \see resizeTimer
1693  *
1694  * \image html jkqtplotter_fastresizing.gif
1695  */
1696  void delayedResizeEvent();
1697 
1698  /** \brief connected to plotScalingRecalculated() of the masterPlotter */
1699  void masterPlotScalingRecalculated();
1700 
1701  /** \brief called whenever the zoom changes in plotter */
1702  void pzoomChangedLocally(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender);
1703 
1704  /** \brief emitted before the plot scaling has been recalculated */
1705  void intBeforePlotScalingRecalculate();
1706  /** \brief called from a menu entry that encodes the graph ID */
1707  void reactGraphVisible(bool visible);
1708 
1709  /** \brief action that activates the pan viewport tool \see resetMouseLeftAction(), setMouseLeftActionAsToolTip() */
1710  void setMouseLeftActionAsPanView();
1711  /** \brief action that activates the zoom rectangle tool \see resetMouseLeftAction(), setMouseLeftActionAsToolTip() */
1712  void setMouseLeftActionAsZoomRect();
1713  /** \brief action that activates the ruler tool \see resetMouseLeftAction(), setMouseLeftActionAsToolTip() */
1714  void setMouseLeftActionAsRuler();
1715  /** \brief action that activates the tooltip tool \see setMouseLeftActionAsRuler(), resetMouseLeftAction() */
1716  void setMouseLeftActionAsToolTip();
1717  /** \brief resets any previously set override action for the left mouse-button, un-modified \see setMouseLeftActionAsRuler(), setMouseLeftActionAsToolTip() */
1718  void resetMouseLeftAction();
1719 
1720 };
1721 
1722 /** \brief qHash-variant used by JKQTPlotter
1723  * \internal
1724  * \ingroup jkqtpplottersupprt
1725 */
1726 template<>
1727 inline uint qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, uint seed ) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) {
1728  return static_cast<uint>(key.first)+static_cast<uint>(key.second);
1729 }
1730 
1731 /** \brief qHash-variant used by JKQTPlotter
1732  * \internal
1733  * \ingroup jkqtpplottersupprt
1734 */
1735 template<>
1736 inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) {
1737  return static_cast<uint>(key);
1738 }
1739 
1740 /** \brief qHash-variant used by JKQTPlotter
1741  * \internal
1742  * \ingroup jkqtpplottersupprt
1743 */
1744 template<>
1745 inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) {
1746  return static_cast<uint>(key);
1747 }
1748 
1749 #endif // JKQTPLOTTER_H
JKQTPlotter::getDatastore
JKQTPDatastore * getDatastore()
returns a pointer to the datastore used by this object
Definition: jkqtplotter.h:651
JKQTPlotter::actMouseLeftAsDefault
QAction * actMouseLeftAsDefault
action that activates the default action, set in plotterStyle!
Definition: jkqtplotter.h:1679
JKQTPMouseWheelActions
JKQTPMouseWheelActions
actions that can be bound to a mouse wheel event
Definition: jkqtptools.h:146
JKQTPlotter::actMouseLeftAsZoomRect
QAction * actMouseLeftAsZoomRect
action that activates the zoom rectangle tool (override!)
Definition: jkqtplotter.h:1685
JKQTPLOTTER_LIB_EXPORT
#define JKQTPLOTTER_LIB_EXPORT
Definition: jkqtplotter_imexport.h:98
JKQTPlotter::mousePosX
double mousePosX
x-position of the mouse during the last mouseMoveEvent() calls (in plot coordinates)
Definition: jkqtplotter.h:1597
JKQTPlotter::actMouseLeftAsToolTip
QAction * actMouseLeftAsToolTip
action that activates the tooltip tool (override!)
Definition: jkqtplotter.h:1683
JKQTBasePlotter::SynchronizationDirection
SynchronizationDirection
denotes, which axes to synchronize in synchronizeToMaster()
Definition: jkqtpbaseplotter.h:970
JKQTPlotter::getNextStyle
int getNextStyle()
gets the next unused style id, i.e. the smalles number >=0 which is not contained in usedStyles
Definition: jkqtplotter.h:847
JKQTPlotter::saveData
void saveData(const QString &filename=QString(""), const QString &format=QString(""))
save the data used for the current plot. The file format is extracted from the file extension (csv,...
Definition: jkqtplotter.h:995
JKQTPlotter::actgrpMouseLeft
QActionGroup * actgrpMouseLeft
action group, that groups the actMouseLeft... actions
Definition: jkqtplotter.h:1677
JKQTPlotter::actMouseLeftAsRuler
QAction * actMouseLeftAsRuler
action that activates the ruler tool (override!)
Definition: jkqtplotter.h:1681
JKQTPlotter::setY
void setY(double yminn, double ymaxx)
sets the y-range of the plot (minimum and maximum y-value on the y-axis)
Definition: jkqtplotter.h:1212
JKQTPlotter::setX
void setX(double xminn, double xmaxx)
sets the x-range of the plot (minimum and maximum x-value on the x-axis)
Definition: jkqtplotter.h:1196
JKQTPlotter::addGraph
size_t addGraph(JKQTPPlotElement *gr)
add a new graph, returns it's position in the graphs list
Definition: jkqtplotter.h:784
JKQTPlotter::print
void print(QPrinter *printer=nullptr)
print the current plot, if printer is nullptr a printer selection dialog is displayed
Definition: jkqtplotter.h:1000
JKQTPlotter::plotter
JKQTBasePlotter * plotter
JKQTBasePlotter used to plot.
Definition: jkqtplotter.h:1437
JKQTPlotter::setShowZeroAxes
void setShowZeroAxes(bool showXY)
switches the visibility of the zero-axes associated with the x- and y-axis
Definition: jkqtplotter.h:977
JKQTPlotter::imageNoOverlays
QImage imageNoOverlays
this stores the currently displayed plot
Definition: jkqtplotter.h:1502
JKQTPlotter::mouseContextX
double mouseContextX
x-position of the mouse (in plot coordinates) when a user mouse-action was started (e....
Definition: jkqtplotter.h:1615
JKQTPlotter::getAbsoluteYMin
double getAbsoluteYMin() const
returns the absolute y-axis min
Definition: jkqtplotter.h:838
JKQTPlotter::addGraphs
void addGraphs(const TJKQTPGraphContainer &gr, QVector< size_t > *graphIDsOut=nullptr)
add a new graphs from a QVector<JKQTPPlotElement*>, QList<JKQTPPlotElement*>, std::vector<JKQTPPlotEl...
Definition: jkqtplotter.h:815
JKQTPMouseDragActionsHashMapIterator
JKQTPMouseDragActionsHashMap::const_iterator JKQTPMouseDragActionsHashMapIterator
iterator for JKQTPMouseDragActionsHashMap
Definition: jkqtptools.h:192
JKQTPlotter::getPlotStyle
JKQTBasePlotter::JKQTPPen getPlotStyle(int i) const
returns a QPen object for the i-th plot style
Definition: jkqtplotter.h:852
JKQTPlotter::setMinorGridColor
void setMinorGridColor(QColor color)
sets the color of all minor grid lines
Definition: jkqtplotter.h:937
JKQTPlotter::getXAxis
const JKQTPHorizontalAxis * getXAxis() const
returns the coordinate axis object for the x-axis as a const pointer
Definition: jkqtplotter.h:750
JKQTPContextMenuModes
JKQTPContextMenuModes
modes for the context menu
Definition: jkqtptools.h:167
JKQTPlotter::contextMenu
QMenu * contextMenu
the context menu object used by this JKQTPlotter
Definition: jkqtplotter.h:1611
qHash
uint qHash(const QPair< Qt::MouseButton, Qt::KeyboardModifiers > &key, uint seed) noexcept(noexcept(qHash(key.first, seed)) &&noexcept(qHash(key.second, seed)))
qHash-variant used by JKQTPlotter
Definition: jkqtplotter.h:1727
JKQTPlotter::zoomOut
void zoomOut(double factor=2.0)
zooms out of the graph (the same as turning the mouse wheel) by the given factor
Definition: jkqtplotter.h:1032
JKQTPlotter::copyDataMatlab
void copyDataMatlab()
copy displayed data to cpliboard in Matlab syntax
Definition: jkqtplotter.h:1010
JKQTPlotter::setEmittingSignalsEnabled
void setEmittingSignalsEnabled(bool sig)
specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate...
Definition: jkqtplotter.h:671
JKQTPlotter::resizeTimer
QTimer resizeTimer
timer used while the graph is resized to delay the redrawing with new size (in the meantime,...
Definition: jkqtplotter.h:1649
JKQTPlotter::contextSubMenus
QList< QMenu * > contextSubMenus
internal storage for sub-menu entries of the internal contextMenu object, based on the actions return...
Definition: jkqtplotter.h:1625
JKQTBasePlotter::JKQTPPen
represents a pen, when plotting in JKQTPlotter/JKQTBasePlotter
Definition: jkqtpbaseplotter.h:568
JKQTPlotter::mouseDragRectYEndPixel
int mouseDragRectYEndPixel
when draging the mouse this contains the y-coordinate the mouse is currently pointing to (in pixels)
Definition: jkqtplotter.h:1458
JKQTPlotter::oldImage
QImage oldImage
this can be used when drawing a zoom rectangle to store an unchanged copy of the currently displayed ...
Definition: jkqtplotter.h:1507
JKQTPlotter::mouseDragRectXEndPixel
int mouseDragRectXEndPixel
when draging the mouse this contains the x-coordinate the mouse is currently pointing to (in pixels)
Definition: jkqtplotter.h:1454
JKVanishQToolBar
a modified QToolBar which vanishes when the mouse leaves the toolbar.
Definition: jkvanishqtoolbar.h:38
JKQTPlotter::mouseDragRectYStartPixel
int mouseDragRectYStartPixel
when zooming by moving the mouse this contains the y-coordinate the user clicked on (in pixels)
Definition: jkqtplotter.h:1469
JKQTPlotter::doDrawing
bool doDrawing
indicates whether the plot is updated automatically at the moment
Definition: jkqtplotter.h:1434
JKQTPlotter::MouseDragMarker::graph
JKQTPPlotElement * graph
graph that created that marker
Definition: jkqtplotter.h:1492
JKQTPlotter::mouseDragMarkers
QList< MouseDragMarker > mouseDragMarkers
internal list of markers to be drawn by paintUserAction()
Definition: jkqtplotter.h:1495
JKQTPlotter::masterPlotterY
QPointer< JKQTPlotter > masterPlotterY
the master plotter, this plotter is connected to in y-direction.
Definition: jkqtplotter.h:1591
JKQTPlotter::setMinorGridWidth
void setMinorGridWidth(double __value)
sets the width of all minor grid lines
Definition: jkqtplotter.h:949
JKQTPlotter::MouseDragAction::valid
bool valid
Definition: jkqtplotter.h:1407
JKQTPVerticalAxis
implements a vertical axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoordin...
Definition: jkqtpcoordinateaxes.h:740
JKQTPlotter::MouseDragMarker::pos
QPoint pos
position of the marker in screen pixels
Definition: jkqtplotter.h:1482
JKQTPMouseDoubleClickActionsHashMapIterator
JKQTPMouseDoubleClickActionsHashMap::const_iterator JKQTPMouseDoubleClickActionsHashMapIterator
iterator for JKQTPMouseDoubleClickActionsHashMap
Definition: jkqtptools.h:206
JKQTPlotter::masterPlotterX
QPointer< JKQTPlotter > masterPlotterX
the master plotter, this plotter is connected to in x-direction.
Definition: jkqtplotter.h:1589
JKQTPlotter::mouseDragRectYStart
double mouseDragRectYStart
when draging the mouse this contains the y-coordinate the user clicked on (in plot coordinates)
Definition: jkqtplotter.h:1466
JKQTPlotter::MouseDragMarker::label
QString label
marker label
Definition: jkqtplotter.h:1484
JKQTPlotter::image
QImage image
this stores the currently displayed plot
Definition: jkqtplotter.h:1499
JKQTPlotter::magnification
double magnification
magnification factor for the display of the plot
Definition: jkqtplotter.h:1601
JKQTPlotter::MouseDragAction::mode
JKQTPMouseDragActions mode
Definition: jkqtplotter.h:1401
JKQTPlotter::useInternalDatastore
void useInternalDatastore()
tells the plotter object to use an internal datastore. A new internal datastore object is generated o...
Definition: jkqtplotter.h:665
JKQTPlotter::minSize
QSize minSize
current minimal size of the JKQTPlotter widget to properly display the plot
Definition: jkqtplotter.h:1603
initJKQTPlotterResources
JKQTPLOTTER_LIB_EXPORT void initJKQTPlotterResources()
initialized Qt-ressources necessary for JKQTPlotter
JKQTPlotter::getPlotter
JKQTBasePlotter * getPlotter() const
returns the class internally used for plotting
Definition: jkqtplotter.h:463
JKQTPUserActionMarkerType
JKQTPUserActionMarkerType
Styles in which to mark single positions during user actions in JKQTPlotter.
Definition: jkqtptools.h:65
JKQTPlotter::getGraphCount
size_t getGraphCount()
returns the number of graphs
Definition: jkqtplotter.h:758
JKQTBasePlotter::sdXYAxes
x- and y-axis
Definition: jkqtpbaseplotter.h:973
JKQTPlotter::saveImage
void saveImage(const QString &filename=QString(""), bool displayPreview=true)
save the current plot as an image file, with the current widget aspect ratio, if filename is empty a ...
Definition: jkqtplotter.h:983
JKQTPlotter::clearGraphs
void clearGraphs(bool deleteGraphs=true)
remove all plots
Definition: jkqtplotter.h:775
JKQTPlotter::mouseDragRectYEnd
double mouseDragRectYEnd
when zooming by moving the mouse this contains the y-coordinate the mouse is currently pointing to
Definition: jkqtplotter.h:1474
JKQTPlotter::MouseDragMarker
describes a marker to be drawn by paintUserAction()
Definition: jkqtplotter.h:1477
JKQTPlotter::menuSpecialContextMenu
QMenu * menuSpecialContextMenu
use this QMenu instance instead of the standard context menu of this widget
Definition: jkqtplotter.h:1513
JKQTPlotter::MouseDragAction
ties a MouseActionMode to a mouse-button and a keyboard-modifier
Definition: jkqtplotter.h:1397
JKQTPlotter::getGraph
JKQTPPlotElement * getGraph(size_t i)
returns the i -th graph (of type JKQTPPlotElement) in this plotter instance
Definition: jkqtplotter.h:755
JKQTPlotter::actMouseLeftAsPanView
QAction * actMouseLeftAsPanView
action that activates the pan view tool (override!)
Definition: jkqtplotter.h:1687
JKQTPlotter::getConstplotter
const JKQTBasePlotter * getConstplotter() const
returns the class internally used for plotting
Definition: jkqtplotter.h:465
JKQTPlotter::mouseDragingRectangle
bool mouseDragingRectangle
this is set true if we are drawing a zoom rectangle
Definition: jkqtplotter.h:1444
JKQTPlotter::mouseContextY
double mouseContextY
y-position of the mouse (in plot coordinates) when a user mouse-action was started (e....
Definition: jkqtplotter.h:1617
JKQTPMouseDoubleClickActions
JKQTPMouseDoubleClickActions
actions that can be bound to a double-click of the mouse
Definition: jkqtptools.h:122
JKQTPlotter::getYAxis
const JKQTPVerticalAxis * getYAxis() const
returns the coordinate axis object for the y-axis as a const pointer
Definition: jkqtplotter.h:752
JKQTPlotter::isEmittingSignalsEnabled
bool isEmittingSignalsEnabled()
returns whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate()
Definition: jkqtplotter.h:673
JKQTPlotterStyle
Support Class for JKQTPlotter, which summarizes all proeprties that define the visual styling of a JK...
Definition: jkqtplotterstyle.h:39
JKQTPlotter::deleteGraph
void deleteGraph(JKQTPPlotElement *gr, bool deletegraph=true)
remove the given graph, if it is contained
Definition: jkqtplotter.h:767
JKQTPlotter::setGridWidth
void setGridWidth(double __value)
sets the width of all Major grid lines
Definition: jkqtplotter.h:943
JKQTPlotter::zoom
void zoom(double nxmin, double nxmax, double nymin, double nymax)
sets x/ymin and x/ymax to the supplied values and replots the graph (zoom operation!...
Definition: jkqtplotter.h:916
JKQTPlotter::moveGraphBottom
size_t moveGraphBottom(JKQTPPlotElement *gr)
move the given graph to the top, or add it, if it is not yet contained
Definition: jkqtplotter.h:802
JKQTPlotter::MouseDragMarker::title
QString title
graph label
Definition: jkqtplotter.h:1486
JKQTPlotter::setMinorGridStyle
void setMinorGridStyle(Qt::PenStyle __value)
sets the style of all minor grid lines
Definition: jkqtplotter.h:961
JKQTPlotter::getAbsoluteXMin
double getAbsoluteXMin() const
returns the absolute x-axis min
Definition: jkqtplotter.h:833
JKQTPlotter::MouseDragAction::modifier
Qt::KeyboardModifiers modifier
Definition: jkqtplotter.h:1402
JKQTPlotter::mouseLastClickX
int mouseLastClickX
x-position of the last mouse-click (in screen pixels)
Definition: jkqtplotter.h:1619
JKQTPlotter::deleteGraph
void deleteGraph(size_t i, bool deletegraph=true)
remove the i-th graph
Definition: jkqtplotter.h:761
JKQTPlotter::getYMax
double getYMax() const
returns the current y-axis max
Definition: jkqtplotter.h:828
JKQTPlotter::zoomToFit
void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05)
this method zooms the graph so that all plotted datapoints are visible.
Definition: jkqtplotter.h:1025
JKQTPMouseDragActions
JKQTPMouseDragActions
Availble action this JKQtPlotter can perform when mouse events occur. This allows you to e....
Definition: jkqtptools.h:92
JKQTPlotter::MouseDragAction::mouseButton
Qt::MouseButton mouseButton
Definition: jkqtplotter.h:1403
JKQTPlotter::toolbar
JKVanishQToolBar * toolbar
toolbar class used for user input
Definition: jkqtplotter.h:1518
JKQTPMouseWheelActionsHashMapIterator
JKQTPMouseWheelActionsHashMap::const_iterator JKQTPMouseWheelActionsHashMapIterator
iterator for JKQTPMouseWheelActionsHashMap
Definition: jkqtptools.h:199
JKQTPlotter::MouseDragMarker::MouseDragMarker
MouseDragMarker(const QPoint &pos_, const QString &label_, const QString &title_, const QColor &color_, const QImage &keymarker_=QImage(), JKQTPPlotElement *_graph=nullptr)
Definition: jkqtplotter.h:1478
JKQTPlotter::getYMin
double getYMin() const
returns the current y-axis min
Definition: jkqtplotter.h:825
JKQTPlotter::setGrid
void setGrid(bool val)
sets whether to plot grid lines or not
Definition: jkqtplotter.h:925
JKQTPlotter::useExternalDatastore
void useExternalDatastore(JKQTPDatastore *newStore)
tells the plotter object to use the given external datastore.
Definition: jkqtplotter.h:659
JKQTPlotter::MouseDragMarker::keyMarker
QImage keyMarker
key marker image
Definition: jkqtplotter.h:1490
JKQTPMouseDragActionsHashMap
QHash< QPair< Qt::MouseButton, Qt::KeyboardModifiers >, JKQTPMouseDragActions > JKQTPMouseDragActionsHashMap
data structure for storage of assigned JKQTPMouseDragActions
Definition: jkqtptools.h:189
JKQTPlotter::mouseDragRectXEnd
double mouseDragRectXEnd
when draging the mouse this contains the x-coordinate the mouse is currently pointing to
Definition: jkqtplotter.h:1463
JKQTPlotter::mousePosY
double mousePosY
y-position of the mouse during the last mouseMoveEvent() calls (in plot coordinates)
Definition: jkqtplotter.h:1599
JKQTPlotter::getAbsoluteYMax
double getAbsoluteYMax() const
returns the absolute y-axis max
Definition: jkqtplotter.h:841
JKQTPlotter::setXY
void setXY(double xminn, double xmaxx, double yminn, double ymaxx)
sets the x- and y-range of the plot (minimum and maximum values on the x-/y-axis)
Definition: jkqtplotter.h:1230
JKQTPlotter::getMagnification
double getMagnification() const
returns the current magnification factor
Definition: jkqtplotter.h:844
JKQTPlotter::MouseDragMarker::color
QColor color
color for the marker
Definition: jkqtplotter.h:1488
JKQTPHorizontalAxis
implements a horizontal axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoord...
Definition: jkqtpcoordinateaxes.h:821
JKQTPlotter::setGridColor
void setGridColor(QColor color)
sets the color of all Major grid lines
Definition: jkqtplotter.h:931
JKQTPlotter::setAbsoluteX
void setAbsoluteX(double xminn, double xmaxx)
sets absolutely limiting x-range of the plot
Definition: jkqtplotter.h:1154
JKQTPlotter
plotter widget for scientific plots (uses JKQTBasePlotter to do the actual drawing)
Definition: jkqtplotter.h:432
JKQTPlotter::contextMenuMode
JKQTPContextMenuModes contextMenuMode
current mode for the default context menu (i.e. the right-click context menu)
Definition: jkqtplotter.h:1613
JKQTPlotter::moveGraphTop
size_t moveGraphTop(JKQTPPlotElement *gr)
move the given graph to the top, or add it, if it is not yet contained
Definition: jkqtplotter.h:793
JKQTPlotter::registeredOverrideMouseDragActionModes
JKQTPMouseDragActionsHashMap registeredOverrideMouseDragActionModes
list of override mouse drag action modes, that override the settings ing plotterStyle....
Definition: jkqtplotter.h:1669
JKQTPlotter::setGridStyle
void setGridStyle(Qt::PenStyle __value)
sets the style of all Major grid lines
Definition: jkqtplotter.h:955
JKQTPlotter::mouseDragRectXStart
double mouseDragRectXStart
when draging the mouse this contains the x-coordinate the user clicked on (in plot coordinates)
Definition: jkqtplotter.h:1447
JKQTPlotter::containsGraph
bool containsGraph(JKQTPPlotElement *gr)
returns true, if the given graph is present
Definition: jkqtplotter.h:764
JKQTPDatastore
This class manages data columns (with entries of type double ), used by JKQTPlotter/JKQTBasePlotter t...
Definition: jkqtpdatastorage.h:280
JKQTPlotter::mouseDragRectXStartPixel
int mouseDragRectXStartPixel
when draging the mouse this contains the x-coordinate the user clicked on (in pixels)
Definition: jkqtplotter.h:1450
JKQTPlotter::currentMouseDragAction
MouseDragAction currentMouseDragAction
the currently executed MouseDragAction
Definition: jkqtplotter.h:1411
JKQTPlotter::getKeyFontSize
double getKeyFontSize() const
font size for key labels [in points]
Definition: jkqtplotter.h:858
JKQTPlotter::setAbsoluteXY
void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx)
sets absolutely limiting x- and y-range of the plot
Definition: jkqtplotter.h:1180
JKQTPlotter::getAbsoluteXMax
double getAbsoluteXMax() const
returns the absolute x-axis max
Definition: jkqtplotter.h:835
JKQTPlotter::setAbsoluteY
void setAbsoluteY(double yminn, double ymaxx)
sets absolute minimum and maximum y-value to plot
Definition: jkqtplotter.h:1165
JKQTPlotter::zoomIn
void zoomIn(double factor=2.0)
zooms into the graph (the same as turning the mouse wheel) by the given factor
Definition: jkqtplotter.h:1030
JKQTPlotter::mouseLastClickY
int mouseLastClickY
y-position of the last mouse-click (in screen pixels)
Definition: jkqtplotter.h:1621
JKQTPlotter::getXMin
double getXMin() const
returns the current x-axis min
Definition: jkqtplotter.h:819
JKQTPlotter::plotterStyle
JKQTPlotterStyle plotterStyle
current style properties for this JKQTPlotter
Definition: jkqtplotter.h:1640
JKQTBasePlotter
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition: jkqtpbaseplotter.h:329
JKQTPlotter::useAsInternalDatastore
void useAsInternalDatastore(JKQTPDatastore *newStore)
tells the plotter object to use the given external datastore and treat it as an internal one (i....
Definition: jkqtplotter.h:662
JKQTPlotter::forceInternalDatastore
void forceInternalDatastore()
tells the plotter object to use an internal datastore (just like useInternalDatastore() ),...
Definition: jkqtplotter.h:668
JKQTPPlotElement
this virtual base class of every element, which is part of a JKQTPlotter plot and may appear in its k...
Definition: jkqtpgraphsbase.h:62
JKQTPlotter::getXAxis
JKQTPHorizontalAxis * getXAxis()
returns the coordinate axis object for the x-axis
Definition: jkqtplotter.h:746
JKQTBasePlotterStyle
Support Class for JKQTBasePlotter, which summarizes all proeprties that define the visual styling of ...
Definition: jkqtpbaseplotterstyle.h:45
JKQTPlotter::getXMax
double getXMax() const
returns the current x-axis max
Definition: jkqtplotter.h:822
JKQTPlotter::getYAxis
JKQTPVerticalAxis * getYAxis()
returns the coordinate axis object for the y-axis
Definition: jkqtplotter.h:748
JKQTPlotter::copyData
void copyData()
copy displayed data to cpliboard
Definition: jkqtplotter.h:1005
JKQTPlotter::setShowZeroAxes
void setShowZeroAxes(bool showX, bool showY)
switches the visibility of the zero-axes associated with the x- and y-axis
Definition: jkqtplotter.h:970