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