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
jkqtpbaseplotter.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 (LGPL) 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 (LGPL) for more details.
15
16 You should have received a copy of the GNU Lesser General Public License (LGPL)
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef JKQTPBASEPLOTTER_H
21#define JKQTPBASEPLOTTER_H
22
23#include "jkqtplotter/jkqtplotter_configmacros.h"
24
25#include "jkqtplotter/jkqtptools.h"
26#include "jkqtplotter/jkqtpdatastorage.h"
27#include "jkqtplotter/jkqtpbaseplotterstyle.h"
28#include "jkqtplotter/jkqtpkey.h"
29#include "jkqtmathtext/jkqtmathtext.h"
30#include "jkqtplotter/jkqtpbaseelements.h"
31#include "jkqtcommon/jkqtpenhancedpainter.h"
32#include "jkqtcommon/jkqtpconcurrencytools.h"
33#include "jkqtplotter/gui/jkqtpenhancedspinboxes.h"
34
35#include <QObject>
36#include <QAction>
37#include <QActionGroup>
38#include <QVector>
39#include <QSettings>
40#include <QColor>
41#include <QMap>
42#include <QVector>
43#include <QPair>
44#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
45# include <QPrinter>
46# include <QtPrintSupport/QPrintPreviewWidget>
47#endif
48#include <QDoubleSpinBox>
49#include <QLabel>
50#include <QPointer>
51#include <QListWidget>
52#include <QComboBox>
53
54#include <vector>
55#include <cmath>
56#include <iostream>
57#include "jkqtplotter/jkqtplotter_imexport.h"
58
59
60
61class JKQTPGraphsModel; // forward
62class JKQTPGraph; // forward
63class JKQTPPlotElement; // forward
64class JKQTPBaseKey; // forward
65
66/** \brief initialized Qt-ressources necessary for JKQTBasePlotter
67 * \ingroup jkqtpplottersupprt */
69
70/** \brief virtual base-class for exporter classes that can be used to save data inot a file
71 * \ingroup jkqtpplottersupprt */
73 public:
75 /** \brief Filter-String for a Qt File-Dialog, e.g. <code>"CSV Files (*.csv)"</code> */
76 virtual QString getFilter() const=0;
77 /** \brief a plugin-ID, i.e. a unique name for this format plugin, e.g. \c MyPluginExport_MATLABMAT */
78 virtual QString getFormatID() const=0;
79 /** \brief returns a list (in lower-case) of the file extensions supported by this plugin, e.g. \c {"mat"} */
80 virtual QStringList getFileExtension() const=0;
81
82 /** \brief actually save the table \a data into file \a filename . The parameter \a columnNames provides a name for each column */
83 virtual void saveJKQTPData(const QString& filename, const QList<QVector<double> >& data, const QStringList& columnNames) const=0;
84};
85
86/** \brief Service from this class to implement a special QPaintDevice as a plugin, that can be registered to JKQTBasePlotter/JKQTPlotter
87 * and then be used to export graphics, use registerPaintDeviceAdapter() to register such a plass
88 * \ingroup jkqtpplottersupprt */
90 public:
92 /** \brief Filter-String for a Qt File-Dialog, e.g. <code>"JPEG Files (*.jpg)"</code> */
93 virtual QString getFilter() const=0;
94 /** \brief Human readable name for the format */
95 virtual QString getFormatName() const=0;
96 /** \brief a plugin-ID, i.e. a unique name for this format plugin, e.g. \c MyPluginExport_JPEG */
97 virtual QString getFormatID() const=0;
98 /** \brief returns a list (in lower-case) of the file extensions supported by this plugin, e.g. \c {"jpg","jpeg"} */
99 virtual QStringList getFileExtension() const=0;
100 virtual bool getSetAbsolutePaperSize() const=0;
101 virtual double getPrintSizeXInMM() const =0;
102 virtual double getPrintSizeYInMM() const =0;
103 virtual bool isPrinter() const=0;
104 /** \brief create a paint device with a given size in pt */
105 virtual QPaintDevice* createPaintdevice(const QString& filename, int widthPix, int heightPix) const=0;
106 /** \brief create a paint device with a given size in millimeters ... the default implementation call createPaintdevice(), assuming the standard logical resolution of the desktop!!!) */
107 virtual QPaintDevice* createPaintdeviceMM(const QString& filename, double widthMM, double heightMM) const;
108};
109
110
111/** \brief base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
112 * \ingroup jkqtpplotterclasses
113 *
114 * This class implements basic functionalities for the plotter classes. Those are:
115 * -# data storage using a JKQTPDatastore object
116 * -# coordinate transforms
117 * -# a set of properties for the graphs (colors, widthes ...) and also a system (see getNextStyle() to automatically
118 * choose a drawing style for different graphs.
119 * -# drawing the coordinate axes, grids ... (logarithmic and linear)
120 * -# saveing and printing the resulting plots
121 * .
122 *
123 * This class is NOT a widget, if you need a plotting widget, use JKQTPlotter. This class may be used to
124 * plot using a JKQTPEnhancedPainter.
125 *
126 * \see JKQTPlotter a QWidget class that displays a JKQTBasePlotter plot on a Qt Window.
127 *
128 *
129 * \tableofcontents
130 *
131 *
132 * \section jkqtplotter_base_datastore Data Storage
133 * As already mentioned this class does not provide means to draw graphs, but it contains a basic mechanism to associate
134 * data with it. This is imeplemented, using a JKQTPDatastore object together with some convenience access methods. No further
135 * data access is implemented and child classes are NOT forced to use this datastore. Hide it if you want. JKQTPlotter shows
136 * how to use it. This class implement a graph management, where graphs simply point to a set of columns inside the datastore
137 * that contain the actual plot data!
138 *
139 * If you call the JKQTBasePlotter::JKQTBasePlotter() constructor with no arguments, it will create an internal
140 * datastore object and you can start adding data by using getDatastore(). If you have an external JKQTPDatastore object you can
141 * give it as parameter to the constructor or use one of the other methods:
142 * - useExternalDatastore(): \copybrief JKQTBasePlotter::useExternalDatastore()
143 * - useAsInternalDatastore(): \copybrief JKQTBasePlotter::useAsInternalDatastore()
144 * - useInternalDatastore(): \copybrief JKQTBasePlotter::useInternalDatastore()
145 * - forceInternalDatastore(): \copybrief JKQTBasePlotter::forceInternalDatastore()
146 *.
147 *
148 *
149 * \section jkqtplotter_base_systems_baseplotter Coordinate Systems and Transformations
150 * These topics are discussed in the help for JKQTPCoordinateAxis. There is a set of coordinate transform
151 * methods (x2p(), y2p(), p2x(), p2y() which only call the respective methods in xAxis and yAxis objects.
152 *
153 *
154 * \section jkqtplotter_base_grids_baseplotter Axis Ticks and Grids
155 *
156 * \subsection jkqtplotter_base_grids_baseplotter_majoraxes Major Coordinate Axes
157 *
158 * JKQTBasePlotter - by default - has two major axes: A horizontal x-axis and a vertical y-axis.
159 *
160 * The plotting of coordinate axes and grids, as well as coordinate transforms is done by
161 * JKQTPCoordinateAxis descendents (see documentation there).
162 *
163 * If you want to set the axis properties, use getXAxis() or getYAxis() to get a pointer to the axis objects which then
164 * may be used to set the axis properties.
165 *
166 * \subsection jkqtplotter_base_grids_baseplotter_secondaryaxes Secondary Coordinate Axes
167 *
168 * In addition a plot may contain secondary axes, as shown below:
169 *
170 * \image html JKQTBasePlotter_addSecondaryYAxis.png
171 *
172 * You can add additional x-axes using addSecondaryXAxis() and y-axes using addSecondaryYAxis().
173 * These functions return a JKQTPCoordinateAxisRef, which can be used to reference these axes, when
174 * calling function like getXAxis() here the default-parameter call getXAxis(JKQTPPrimaryAxis) returns
175 * the primary axis (JKQTPPrimaryAxis may be omitted) and calling getXAxis(JKQTPSecondaryAxis) will return
176 * the first secondary axis and so on.
177 *
178 * In graphs (derived from JKQTPPlotElement) you can use JKQTPPlotElement::setXAxis() and JKQTPPlotElement::setYAxis()
179 * with a JKQTPCoordinateAxisRef as parameter to tell plots to use another axis.
180 *
181 * Using a JKQTPCoordinateAxisRef instead of a pointer to a JKQTPCoordinateAxis allows to exchange the axes in the plot,
182 * while not breaking the graphs.
183 *
184 * Here is a code example of how to use secondary axes:
185 * \code
186 * // construct a new x-axis-object
187 * JKQTPHorizontalAxisBase* secXAxis=new JKQTPHorizontalAxis(plot.getPlotter(), JKQTPPrimaryAxis)
188 * // add it to the plot
189 * auto xAxisRef2=plot.getPlotter()->addSecondaryXAxis(secXAxis);
190 * // ... now you can access it:
191 * plot.getXAxis(xAxisRef2)->setShowZeroAxis(false);
192 * // ... and use it for graphs:
193 * graph2->setXAxis(xAxisRef2);
194 * \endcode
195 *
196 * \see addSecondaryXAxis(), addSecondaryYAxis(), getXAxis(), getYAxis()
197 *
198 *
199 * \section jkqtbaseplotter_appearance_and_style Appearance & Styling of the Graph
200 *
201 *
202 * \subsection jkqtplotter_base_plotsize Plot Sizes & Borders
203 *
204 * JKQTBasePlotter itself is no QWidget. It is merely tool to represent, manage and draw a graph onto any durface.
205 * JKQTPlotter then uses an internal JKQTBasePlotter instance to provide a QWidget.
206 *
207 * Still the JKQTBasePlotter needs a way to represent the location of the graph, the graph axes etc. inside
208 * a drawing rectangle (of size widgetWidth * widgetHeight ). The plot borders are then offsets to the plot
209 * indise that rectangele. This image illustrated the principle:
210 *
211 * \image html plot_widget_orientation.png
212 *
213 * When the plot is actually drawn, it may happen, that additional elements need to be positioned between the
214 * actual coordinate rectangle and the widget worder (e.g. axis labels, ticks, color bars etc.). Therefore
215 * this objects manages a set of internally calculated variables that also incorporate those dynamic elements.
216 * These are e.g. internalPlotBorderLeft, internalPlotBorderTop, internalPlotBorderRight, ... Their names all
217 * start with \c internal... .
218 *
219 *
220 * \subsection jkqtplotter_base_aspectratios Aspect Ratios
221 * First note that this functionality is only available and activated if both axes are linear!
222 *
223 * You can set two different aspect ratios:
224 * - The ratio of plotWidth/plotHeight (setAspectRatio(), setMaintainAspectRatio()) will keep the plots pixel-width and height at a certain value.
225 * \f[ \mbox{aspectRatio}=\frac{\mbox{plotWidth}}{\mbox{plotHeight}} \f]
226 * - The ratio of (xmax-xmin)/(ymax-ymin) (setAxisAspectRatio(), setMaintainAxisAspectRatio()) will keep the displayed axis ranges in a certain ratio.
227 * \f[ \mbox{axisAspectRatio}=\frac{\left|x_\text{max}-x_\text{min}\right|}{\left|y_\text{max}-y_\text{min}\right|} \f]
228 * .
229 * So to achieve different effects, use these combinations:
230 * - you have a 200x100 range where each 1x1-pixel should have an aspect ratio of 4:
231 * \code
232 * setAspectRatio(200.0/100.0);
233 * setAxisAspectRatio(4.0*getAspectRatio());
234 * \endcode
235 * .
236 *
237 *
238 * \subsection jkqtplotter_base_key Graph Keys (Legends)
239 * This class provides means to plot a key together with the functions. The plotting is only partially implemented in this base class, and has to be
240 * implemented by child classes, as no graph management, that could provide a title for a specific graph, is implemented here. Key Plotting is
241 * performed in the plotKey() method. This method basically draws a frame and background and then calls plotKeyContent() to draw the actual contents.
242 * The size of the key is determined by a call to getKeyExtent(), while it's position and plotting style is determined by the \c key_... parameters.
243 * If getKeyExtent() returns 0 for height or width, no key is plotted. The \c key_... parameters are designed to be rather common for any usual kind
244 * of key, so any implementation of key should be able to use them to parametrize the output. Note however that additional parameters might be defined
245 * in child classes.
246 *
247 * \image html plot_key.png
248 *
249 * As it may be convenient to position the key completely outside the graph this class may change the plotBorders to make the key fit outside
250 * SO if you use a keyPosition \b outside the graph you should NOT keep any space for the key in the margins, as the program will change them to
251 * accomodate the size of the key. If you select an \b inside key position the key will be plotted OVER the graph, i.e. the margins won't be changed
252 * Note that the margin change is internal and not visible in the class interface!
253 *
254 * There is also a possibility to determine the size of the key automatically, so all text fits in. This is activted by the property keyAutosize ( \copybrief JKQTPKeyStyle::autosize ). If this
255 * is \c true the function getKeyExtent() has to check the width of every key item and take it into account when calculating the width and height of the
256 * key content. By default this feature is switched ON.
257 *
258 *
259 * \section jkqtbaseplotter_dataexport_print Printing, Saving & Exporting
260 *
261 * \subsection jkqtplotter_base_saveprint Saving and Printing Graphs
262 * This class implement a set of function to save and print the graphs:
263 * - print() prints the graph on a QPrinter object
264 * - saveAsPixelImage() saves the plot into a pixel image file (PNG, TIFF, ... formats, as supported by Qt)
265 * - saveAsPDF() saves the graph as a PDF file (using the Qt printing engine)
266 * - saveAsSVG() saves the graph as a SVG file (using the Qt SVG library)
267 * - saveImage() saves the graph
268 * .
269 * You can also copy the contents of the plot into the clipboard:
270 * - copyPixelImage()
271 * .
272 *
273 * \subsection jkqtplotter_base_dataexport Exporting Graph Data
274 * This class implement a set of function to save the data of the graphs:
275 * - saveData() saves the data of the plot
276 * - saveAsCSV() saves the data of the plot as comma separated values
277 * - saveAsSYLK() saves the data of the plot as SYLK spreadsheet
278 * - saveAsDIF() saves the data of the plot as data interchange format file
279 * - saveAsMatlab() saves the data of the plot as a CSV file suitable for Matlab
280 * - saveAsSemicolonSV() saves the data of the plot as a Semicolon Separated Values (SSV)
281 * - saveAsTabSV() saves the data of the plot as a Tabulator Separated Values (CSV) file
282 * - saveAsGerExcelCSV() saves the data of the plot as a Text file (SSV) suitable for german excel, i.e. with comma as decimal separator
283 * .
284 * You can also copy the graphs' data into the clipboard:
285 * - copyData()
286 * - copyDataMatlab()
287 * .
288 *
289 *
290 * \section JKQTBASEPLOTTER_SYNCMULTIPLOT Synchronizing Several Plots
291 *
292 * Often a single plot is not sufficient, but several plots need to be aligned with respect to each other:
293 *
294 * \image html multiplot.png
295 *
296 * This can be achieved by putting several JKQTPlotter instances into a
297 * <a href="http://doc.qt.io/qt-5/layout.html">Qt Layout</a>. Then you can fill each plot differently and
298 * set the x-/y-range of each plot by hand. This method works for simple cases, but has several drawbacks:
299 * - Due to the independent and automatic layouting of each plot, the axes do not need to be aligned properly<br>
300 * \image html jkqtbaseplotter_synchronization_unequalaxes.png
301 * - When you print the plot, the printing does not know about the layout and the other plots in it. Therefor
302 * it will only print the plot itself.<br>
303 * \image html jkqtbaseplotter_synchronization_nogridprint.png "Printing with grid-printing-mode deactivated"<br>
304 * \image html jkqtbaseplotter_synchronization_withgridprint.png "Printing with grid-printing-mode activated"
305 * - when you zoom/pan in one of the plots (e.g. using the mouse), the other plots will not adapt their
306 * axes to match the new area, but especially in cases as in the image above it would be beneficial,
307 * that the x-axis of the plot at the bottom follows the x-axis of the plot above etc.<br>
308 * \image html jkqtbaseplotter_synchronization_nonsyncedxrange.png
309 * .
310 *
311 *
312 * To overcome these limitations, JKQTPlotter (and JKQTBasePlotter) offer an API with which you can declare relations between
313 * different plots (one of them is made the master) and you can synchronize the axes of two plots, when
314 * zooming (also when calling e.g. zoomToFit() or setXY() ). This API is:
315 * - \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_SYNC
316 * - \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT
317 * .
318 *
319 * \subsection JKQTBASEPLOTTER_SYNCMULTIPLOT_SYNC Synchronizing Axis Range & Plot Width
320 *
321 * You can synchronize the plot width and axis range between two JKQTPlotter instaces using:
322 * - synchronizeToMaster() / JKQTBasePlotter::synchronizeToMaster() synchronizes the parent JKQTPlotter with another JKQTPlotter. With two boolean-parameters
323 * you can specify the axes to be synchronized. E.g. in the case above, you would call:
324 * \code
325 * // synchronize width/x-axis of plotResid to width/x-axis of plotMain
326 * plotResid->synchronizeToMaster(plotMain, JKQTBasePlotter::sdXAxis, true, true, true);
327 *
328 * // synchronize y-axis of width/plotResidHist to y-axis of width/plotResid
329 * plotResidHist->synchronizeToMaster(plotResid, JKQTBasePlotter::sdYAxis, true, true, true);
330 * \endcode
331 * This will synchronize the x-axes of the top (\c plotMain ) and bottom-left plot (\c plotResid ),
332 * as well as the y-axes of the bottom-left (\c plotResid ) and bottom-right plot (\c plotResidHist ).
333 * After this call they will have the same size in screen pixels and always span the same range
334 * in plot coordinates.
335 * - synchronizeXToMaster() / JKQTBasePlotter::synchronizeXToMaster() like synchronizeToMaster() / JKQTBasePlotter::synchronizeToMaster(),
336 * but synchronizes only the x-axes
337 * - synchronizeYToMaster() / JKQTBasePlotter::synchronizeYToMaster() like synchronizeToMaster() / JKQTBasePlotter::synchronizeToMaster(),
338 * but synchronizes only the y-axes
339 * - resetMasterSynchronization() / JKQTBasePlotter::resetMasterSynchronization() deletes all synchronizations
340 * from the JKQTPlotter
341 * .
342 *
343 * \see See \ref JKQTPlotterMultiPlotLayout for an extensive example of the functionality.
344 *
345 *
346 * \subsection JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT Grid Printing/Declaring Relations between Plots
347 *
348 * Usually each JKQTPlotter/JKQTBasePlotter prints or exports only itself. But in many cases you might want to
349 * add several plots that form a grid layout and also want to export them as one image/print them on one page.
350 * To do this, JKQTPlotter/JKQTBasePlotter offers the <b>"grid printing" mode</b>. In this mode, you can declare
351 * relations between different JKQTPlotters/JKQTBasePlotters by putting them in a rectangular grid (like in a
352 * <a reh="http://doc.qt.io/qt-5/qgridlayout.html">QGridLayout</a>). then any export/print action will draw all (explicitly)
353 * decalred graphs.
354 *
355 * \image html jkqtplotter_gridprint.png
356 *
357 * The grid printing API is composed of these functions:
358 * - setGridPrinting() enables grid printing for this JKQTPlotter. If set to \c true , and you print afterwards,
359 * the printout (or export) will not only contain the plot itself, but also additional plots that were
360 * declared using addGridPrintingPlotter() (see below).
361 * - addGridPrintingPlotter() add a new plotter \a plotterOther for grid printing mode, at location \a x / \a y
362 * E.g. in the example shown above, you could call:
363 * \code
364 * plotMain->setGridPrinting(true);
365 * plotMain->addGridPrintingPlotter(0,1,plotResid);
366 * plotMain->addGridPrintingPlotter(1,1,plotResidHist);
367 * \endcode
368 * - setGridPrintingCurrentX() / setGridPrintingCurrentY() / setGridPrintingCurrentPos()
369 * sets the location of the calling plot inside the grid. <i>By default each plot assumes to be at (0,0).</i>
370 * - clearGridPrintingPlotters() clear all additional plotters for grid printing mode
371 * .
372 *
373 * \see See \ref JKQTPlotterMultiPlotLayout for an extensive example of the functionality.
374 *
375 *
376 * \section jkqtplotter_base_userprops User Properties
377 * There is a subset of options that describe how the user interacted with the plotter (export/print scaling factors etc, save directories,
378 * other export settings, ...). These are not stored/loaded using saveSettings() and loadSettings(), but using saveUserSettings() and loadUserSettings().
379 * These methods MAY (strictly optional and turned off by default) be called by saveSettings() and loadSettings(), if the property userSettigsFilename ( \copybrief userSettigsFilename )is
380 * set (not-empty). In this case the suer settings are stored/loaded also everytime they are changed by the user or programmatically.
381 *
382 * \section jkqtplotter_usage_baseplotter JKQTBasePlotter Usage
383 *
384 * \subsection jkqtplotter_usage_baseplotter_in_widget JKQTBasePlotter as Basis for JKQTPlotter
385 *
386 * Most commonly this invisible plotter class is used as basis for the widget JKQTPlotter.
387 * \see JKQTPlotter
388 *
389 * \subsection jkqtplotter_usage_baseplotter_standalone JKQTBasePlotter Standalone Usage (non-visible class)
390 *
391 * \copydetails jkqtplotter_general_usage_jkqtbaseplotter
392 *
393 */
395 Q_OBJECT
396 public:
397 typedef QMap<QString, QList<QPointer<QAction> > > AdditionalActionsMap;
398 typedef QMapIterator<QString, QList<QPointer<QAction> > > AdditionalActionsMapIterator;
399
400 /** \brief set a global preset/default value for the userSettigsFilename and userSettigsPrefix properties of JKQTBasePlotter
401 *
402 * These presets are application global and will be used ONLY on initialization of a JKQTBasePlotter. You can overwrite them
403 * on a local-basis for each JKQTBasePrinter separately. The changed values from this function call will only take effect for
404 * newly created plotters AFTER the function call!
405 */
406 static void setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, const QString& userSettigsPrefix);
407
408 /** \brief register a user-defined QPaintDevice (with factory JKQTPPaintDeviceAdapter) as a plugin to JKQTBasePlotter/JKQTPlotter,
409 * which will use it to export graphics */
411 /** \brief de-register a JKQTPPaintDeviceAdapter from JKQTBasePlotter/JKQTPlotter */
413
414
415
416
417 /** \brief register a JKQTPSaveDataAdapter with JKQTPlotter/JKQTBasePlotter that can be used to export data from the internal datastore into a file */
419 /** \brief de-register a JKQTPSaveDataAdapter from JKQTPlotter/JKQTBasePlotter */
421
422
423
424
425//////////////////////////////////////////////////////////////////////////////////////////////////////////////
426/** @name Konstruktion and Destruction */
427/**@{*/
428
429 /** \brief class constructor
430 *
431 * if \a datastore_internal is \c true then the constructor will create an internal datastore object. The datastore
432 * will be managed (freed) by this class. If \a datastore_internal is \c false the class will use the datastore provided
433 * in \a datast as an external datastore. You can modify this later by using useInternalDatastore() and useExternalDatastore().
434 */
435 explicit JKQTBasePlotter(bool datastore_internal, QObject* parent=nullptr, JKQTPDatastore* datast=nullptr);
436
438
439 /** \brief class destructor */
441/**@}*/
442
443
444//////////////////////////////////////////////////////////////////////////////////////////////////////////////
445/** @name Plot Data Storage/Management (JKQTPDatastore) */
446/**@{*/
447
448 /** \brief returns a pointer to the datastore used by this object */
449 inline JKQTPDatastore* getDatastore() { return datastore; }
450
451
452
453 /** \brief returns a pointer to the datastore used by this object */
454 inline const JKQTPDatastore* getDatastore() const { return datastore; }
455
456 /** \brief tells the plotter object to use the given external datastore.
457 *
458 * If the current datastore is internally managed, this method will free that object and use the supplied datastore
459 * with external management. If the current datastore is already external, this method will simply replace it by the
460 * new one.
461 */
463
464 /** \brief tells the plotter object to use the given external datastore and treat it as an internal one (i.e. free it
465 * when the plotter object ist destroyed.
466 */
468
469 /** \brief tells the plotter object to use an internal datastore. A new internal datastore object is generated only if
470 * the current datastore is not internal.
471 */
473
474 /** \brief tells the plotter object to use an internal datastore (just like useInternalDatastore() ), but forces the
475 * generation of a new datastore, even if the current one is already internal (the current one will be freed in
476 * the lather case */
478
479
480/**@}*/
481
482
483//////////////////////////////////////////////////////////////////////////////////////////////////////////////
484/** @name Graphs Management */
485/**@{*/
486
487 typedef QVector<JKQTPPlotElement*> GraphsList;
488 typedef QVector<JKQTPPlotElement*>::iterator GraphsIterator;
489 typedef QVector<JKQTPPlotElement*>::const_iterator GraphsConstIterator;
490
491 /** \brief returns model representing all Plots in this plotter and showing their visible/invisible state */
492 inline const JKQTPGraphsModel* getPlotsModel() const { return m_plotsModel; }
493
494 /** \brief returns model representing all Plots in this plotter and showing their visible/invisible state */
495 inline JKQTPGraphsModel* getPlotsModel() { return m_plotsModel; }
496
497
498
499 /** \brief returns description of i'th graph
500 *
501 * \note If you modify the returned graph, a replot may not happen, so call redrawPlot() if the plotter is e.g. embedded in a visible widget to cause a redrawing of the plot!
502 */
504 /** \brief returns description of i'th graph */
505 const JKQTPPlotElement* getGraph(size_t i) const;
506
507 /** \brief returns the number of graphs */
508 size_t getGraphCount() const;
509
510 /** \brief remove the i-th graph */
511 void deleteGraph(size_t i, bool deletegraph=true);
512
513 /** \brief remove the given graph, if it is contained */
514 void deleteGraph(JKQTPPlotElement* gr, bool deletegraph=true);
515
516 /** \brief returns a const list of all graphs */
517 inline const GraphsList& getGraphs() const {
518 return graphs;
519 }
520
521 /** \brief returns a list of all graphs
522 *
523 * \note If you modify the graphs or change their position, a replot may not happen, so call redrawPlot() if the plotter is e.g. embedded in a visible widget to cause a redrawing of the plot!
524 */
526 return graphs;
527 }
528
529 /** \brief returns a const iterator to the first graph */
531 return graphs.cbegin();
532 }
533 /** \brief returns a const iterator behind the last graph */
535 return graphs.cend();
536 }
537 /** \brief returns a const iterator to the first graph */
539 return graphs.begin();
540 }
541 /** \brief returns a const iterator behind the last graph */
543 return graphs.end();
544 }
545 /** \brief returns an iterator to the first graph
546 *
547 * \note If you modify the graphs or change their position, a replot may not happen, so call redrawPlot() if the plotter is e.g. embedded in a visible widget to cause a redrawing of the plot!
548 */
550 return graphs.begin();
551 }
552 /** \brief returns an iterator behind the last graph
553 *
554 * \note If you modify the graphs or change their position, a replot may not happen, so call redrawPlot() if the plotter is e.g. embedded in a visible widget to cause a redrawing of the plot!
555 */
557 return graphs.end();
558 }
559 /** \brief add a new graph at the end of the graphs, if the graph is already in the plot, it is moved to the end of the list
560 *
561 * \param gr graph object (of type JKQTPPlotElement) to be added. \b Note: The JKQTPlotter takes ownership of graph \a gr .
562 *
563 * \note the added graph is drawn ABOVE/AFTER all other graphs.
564 */
566 inline size_t addGraph(JKQTPPlotElement* gr) { return addGraphOnTop(gr); }
567 /** \brief add a new graph before all other graphs (i.e. at the top of the list of graphs), if the graph is already in the plot, it is moved to the top
568 *
569 * \param gr graph object (of type JKQTPPlotElement) to be added. \b Note: The JKQTPlotter takes ownership of graph \a gr .
570 *
571 * \note the added graph is drawn BELOW/BEFORE all other graphs.
572 */
574
575 /** \brief returns \c true, if the given graph is in this plot */
576 bool containsGraph(const JKQTPPlotElement *gr) const;
577
578 /** \brief move the given graph \a gr to the end of all graphs, so it is drawn */
580 /** \brief move the given graph \a gr to the bottom of all graphs */
582 /** \brief move the given graph to the top */
583 void moveGraphTop(int idx);
584 /** \brief move the given graph to the top */
585 void moveGraphBottom(int idx);
586 /** \brief returns the index of the given graph \a gr in the graphs list, or -1 if it was not found */
587 int indexOfGraph(const JKQTPPlotElement* gr) const;
588
589 /** \brief move the given graph \a gr one item up (i.e. it is drawn later/higher in the z-stack) */
591 /** \brief move the given graph \a gr one item down (i.e. it is drawn earlier/lower in the z-stack) */
593 /** \brief move the graph at position \a idx one item up (i.e. it is drawn later/higher in the z-stack) */
594 void moveGraphUp(int idx);
595 /** \brief move the graph at position \a idx one item down (i.e. it is drawn earlier/lower in the z-stack) */
596 void moveGraphDown(int idx);
597
598 /** \brief add a new graphs from a QVector<JKQTPPlotElement*>, QList<JKQTPPlotElement*>, std::vector<JKQTPPlotElement*> ... or any standard-iterateable container with JKQTPPlotElement*-items
599 *
600 * \tparam TJKQTPGraphContainer a container type with default C++-sytle iterator interface
601 * (i.e. methods \c begin() and \c end() and an iterator, which may be
602 * moved to the next element with the operator \c ++ .
603 * \param gr Container of type TJKQTPGraphContainer, which contains the graphs \b Note: The JKQTPlotter takes ownership of graphs in \a gr .
604 * \param[out] graphIDsOut optional output parameter, the vector will contain the IDs of each graph added to theis plot
605 */
606 template <class TJKQTPGraphContainer>
607 inline void addGraphs(const TJKQTPGraphContainer& gr, QVector<size_t>* graphIDsOut=nullptr) {
608 for (auto it=gr.begin(); it!=gr.end(); ++it) {
609 const auto id=addGraph(*it);
610 if (graphIDsOut) graphIDsOut->push_back(id);
611 }
612 }
613 /** \brief apply functor \a func to all graphs in the plotter. After completing the operation, the graph is updated */
614 void modifyGraphs(const std::function<void(JKQTPPlotElement*)>& func);
615 /** \brief sort the graphs, using functor \a compareLess to find whether a first graph shall be before (i.e. less) than a second graph. After completing the operation, the graph is updated */
616 void sortGraphs(const std::function<bool(const JKQTPPlotElement* , const JKQTPPlotElement* )>& compareLess);
617
618 public Q_SLOTS:
619 /** \brief remove all plots
620 *
621 * \param deleteGraphs if set \c true (default) the graph objects will also be deleted
622 */
623 void clearGraphs(bool deleteGraphs=true);
624
625
626 /** \brief set all graphs in the plotter invisible
627 *
628 * \see setAllGraphsVisible(), setGraphVisible(), JKQTPPlotElement::setVisible() */
630 /** \brief set all graphs in the plotter visible
631 *
632 * \see setAllGraphsInvisible(), setGraphVisible(), JKQTPPlotElement::setVisible() */
634 /** \brief switch visibility of the \a i -th graph to \a visible
635 *
636 * \see setAllGraphsInvisible(), setAllGraphsVisible(), JKQTPPlotElement::setVisible() */
637 void setGraphVisible(int i, bool visible=true);
638 /** \brief switch visibility of the \a i -th graph to \a visible
639 *
640 * \see setAllGraphsInvisible(), setAllGraphsVisible(), JKQTPPlotElement::setVisible() */
641 void setGraphInvisible(int i);
642
643 public:
644
645 /** \brief Functor which can be used as filter predicate for getGraphsXMinMax() or getGraphsYMinMax()
646 *
647 * \see getGraphsXMinMax(), getGraphsYMinMax(), allPlotElements
648 */
649 typedef std::function<bool(const JKQTPPlotElement*)> PlotElementPreciate;
650
651 /** \brief Functor which does not apply any filter to JKQTPPlotElement, e.g. in getGraphsXMinMax() or getGraphsYMinMax()
652 *
653 * \see getGraphsXMinMax(), getGraphsYMinMax(), PlotElementPreciate
654 */
656 inline bool operator()(const JKQTPPlotElement*) const { return true; };
657 };
658 /** \brief filter functor which accepts only those JKQTPPlotElement where JKQTPPlotElement::getXAxisRef()
659 * returns the JKQTPCoordinateAxisRef supplied to the constructor, e.g. in getGraphsXMinMax() or getGraphsYMinMax()
660 *
661 * \see getGraphsXMinMax(), getGraphsYMinMax(), PlotElementPreciate
662 */
664 inline explicit filterPlotElementByXAxis(JKQTPCoordinateAxisRef ref_): ref(ref_) {};
665 inline bool operator()(const JKQTPPlotElement* el) const;
666 private:
668 };
669 /** \brief filter functor which accepts only those JKQTPPlotElement where JKQTPPlotElement::getYAxisRef()
670 * returns the JKQTPCoordinateAxisRef supplied to the constructor, e.g. in getGraphsXMinMax() or getGraphsYMinMax()
671 *
672 * \see getGraphsXMinMax(), getGraphsYMinMax(), PlotElementPreciate
673 */
675 inline explicit filterPlotElementByYAxis(JKQTPCoordinateAxisRef ref_): ref(ref_) {};
676 inline bool operator()(const JKQTPPlotElement* el) const;
677 private:
679 };
680 /** \brief get the maximum and minimum x-value over all graphs in the plot
681 * \param[out] minx smallest x value
682 * \param[out] maxx largest x value
683 * \param[out] smallestGreaterZero smallest data point which is >0 (needed for scaling of logarithmic axes)
684 * \param predicate a PlotElementPreciate, which can be used to limit the JKQTPPlotElement to be evaluated
685 * \returns \c true if at least one matching graph was found and evaluated succcessfully
686 *
687 * The result is given in the two parameters which are call-by-reference parameters!
688 */
689 bool getGraphsXMinMax(double& minx, double& maxx, double& smallestGreaterZero, const PlotElementPreciate &predicate=allPlotElements());
690 /** \brief get the maximum and minimum y-value over all graphs in the plot
691 * \param[out] miny smallest y value
692 * \param[out] maxy largest y value
693 * \param[out] smallestGreaterZero smallest data point which is >0 (needed for scaling of logarithmic axes)
694 * \param predicate a PlotElementPreciate, which can be used to limit the JKQTPPlotElement to be evaluated
695 * \returns \c true if at least one matching graph was found and evaluated succcessfully
696 *
697 * The result is given in the two parameters which are call-by-reference parameters!
698 */
699 bool getGraphsYMinMax(double& miny, double& maxy, double& smallestGreaterZero, const PlotElementPreciate &predicate=allPlotElements());
700/**@}*/
701
702
703
704//////////////////////////////////////////////////////////////////////////////////////////////////////////////
705/** @name Plot Styling & Settings Management */
706/**@{*/
707
708 /** \brief loads all the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object */
709 void loadSettings(const QSettings& settings, const QString& group=QString("plots/"));
710
711 /** \brief saves the plot properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object.
712 *
713 * This method only saves those properties that differ from their default value.
714 */
715 void saveSettings(QSettings& settings, const QString& group=QString("plots/")) const;
716
717
718 /** \brief current style properties for this JKQTBasePlotter
719 *
720 * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
721 */
723
724 /** \brief replace the current style properties for this JKQTBasePlotter
725 *
726 * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
727 */
729 /** \brief replace the current style properties for this JKQTBasePlotter with properties loaded from \a settings
730 *
731 * \param settings the QSettings object to read from
732 * \param group group in \a settings to read from
733 *
734 * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
735 */
736 void loadCurrentPlotterStyle(const QSettings& settings, const QString& group="plots/");
737 /** \brief store the current style properties for this JKQTBasePlotter with properties loaded from \a settings
738 *
739 * \param settings the QSettings object to write to
740 * \param group group in \a settings to write to
741 *
742 * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
743 */
744 void saveCurrentPlotterStyle(QSettings& settings, const QString& group="plots/") const;
745
746
747
748 /** \brief loads the plot user properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object */
749 void loadUserSettings(const QSettings& settings, const QString& group=QString("plots_user/"));
750
751 /** \brief saves the plot user properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object. */
752 void saveUserSettings(QSettings& settings, const QString& group=QString("plots_user/")) const;
753
754
755 /** \brief gets the next unused style id, i.e. the smalles number >=0 which is not contained in usedStyles */
757
758
759 /** \brief represents a pen, when plotting in JKQTPlotter/JKQTBasePlotter
760 * \ingroup jkqtpplottersupprt
761 *
762 * \see getPlotStyle()
763 */
765 protected:
766 QColor m_color;
771 double m_width;
774 Qt::PenStyle m_style;
777 Qt::BrushStyle m_errorFillStyle;
779
780 public:
782 void setSymbolSize(double w);
783 void setSymbolLineWidthF(double w);
784 void setWidthF(double w);
785 void setWidth(double w);
786 void setErrorLineWidth(double w);
787 double width() const;
788 double widthF() const;
789 double errorWidthF() const;
790 double symbolLineWidthF() const;
791 double symbolSize() const;
792 QColor color() const;
793 QColor errorColor() const;
794 QColor errorFillColor() const;
795 void setColor(const QColor& col);
796 Qt::PenStyle style() const;
797 Qt::PenStyle errorStyle() const;
798 void setStyle(Qt::PenStyle s);
799 QColor fillColor() const;
800 void setFillColor(const QColor& col);
801 void setErrorFillColor(const QColor& col);
802 void setErrorLineColor(const QColor& col);
804 void setErrorFillStyle(Qt::BrushStyle s);
806 Qt::BrushStyle errorFillStyle() const;
809 void setSymbolFillColor(QColor c);
810 QColor symbolFillColor() const;
811 };
812
813
814
815 /** \brief returns a QPen object for the i-th plot style */
817
818/**@}*/
819
820
821
822
823//////////////////////////////////////////////////////////////////////////////////////////////////////////////
824/** @name Utilities: Unit Transforms */
825/**@{*/
826
827
828 /** \brief returns the given size in Didot points (0.376 mm) to pixels (with given dots per inch) */
829 inline double didot2px(double pt, double dpi) const {
830 return dpi/25.4*0.376*pt;
831 }
832 /** \brief returns the given size in Didot points (0.376 mm) to pixels (with dpi from painter) */
833 inline double didot2px(double pt, JKQTPEnhancedPainter& painter) const {
834 return didot2px(pt, painter.device()->logicalDpiX());
835 }
836 /** \brief returns the given size in Didot points (0.376 mm) to pixels (with dpi from painter) */
837 inline double didot2px(JKQTPEnhancedPainter& painter, double pt) const {
838 return didot2px(pt, painter.device()->logicalDpiX());
839 }
840
841 /** \brief returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch) */
842 inline double pt2px(double pt, double dpi) const {
843 return dpi*pt/72.0;
844 }
845 /** \brief returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch) */
846 inline double pt2px(double pt, JKQTPEnhancedPainter& painter) const {
847 return pt2px(pt, painter.device()->logicalDpiX());
848 }
849 /** \brief returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch) */
850 inline double pt2px(JKQTPEnhancedPainter& painter, double pt) const {
851 return pt2px(pt, painter.device()->logicalDpiX());
852 }
853
854 /** \brief returns the given size in millimeters to pixels (with given dots per inch) */
855 inline double mm2px(double mm, double dpi) const {
856 return dpi*mm/25.4;
857 }
858 /** \brief returns the given size in millimeters to pixels (with given dots per inch) */
859 inline double mm2px(double mm, JKQTPEnhancedPainter& painter) const {
860 return mm2px(mm, painter.device()->logicalDpiX());
861 }
862 /** \brief returns the given size in millimeters to pixels (with given dots per inch) */
863 inline double mm2px(JKQTPEnhancedPainter& painter, double mm) const {
864 return mm2px(mm, painter.device()->logicalDpiX());
865 }
866
867 /** \brief return x-pixel coordinate from x coordinate, using the primary axis */
868 inline double x2p(double x) const {
869 return xAxis->x2p(x);
870 }
871
872 /** \brief return y-pixel coordinate from y coordinate, using the primary axis */
873 inline double y2p(double y) const {
874 return yAxis->x2p(y);
875 }
876
877 /** \brief return x coordinate from x-pixel, using the primary axis */
878 inline double p2x(double x) const {
879 return xAxis->p2x(x);
880 }
881
882 /** \brief return y coordinate from y-pixel, using the primary axis */
883 inline double p2y(double y) const {
884 return yAxis->p2x(y);
885 }
886/**@}*/
887
888
889
890
891//////////////////////////////////////////////////////////////////////////////////////////////////////////////
892/** @name Access to Plot Properties */
893/**@{*/
894
895
896 /** \brief gets the width of the plot widget */
897 int getWidth();
898
899 /** \brief gets the width of the plot widget */
901
902
903 /** \brief returns the current x-axis min of the primary x-axis
904 *
905 * \see JKQTPCoordinateAxis::getMin()
906 */
907 double getXMin() const;
908
909 /** \brief returns the current x-axis max of the primary x-axis
910 *
911 * \see JKQTPCoordinateAxis::getMax()
912 */
913 double getXMax() const;
914
915 /** \brief returns the current y-axis min of the primary y-axis
916 *
917 * \see JKQTPCoordinateAxis::getMin()
918 */
919 double getYMin() const;
920
921 /** \brief returns the current y-axis max of the primary y-axis
922 *
923 * \see JKQTPCoordinateAxis::getMax()
924 */
925 double getYMax() const;
926
927
928
929
930 /** \brief returns the absolute x-axis min of the primary x-axis. This is the lowest allowed value the the axis min/max.
931 *
932 * \see JKQTPCoordinateAxis::getAbsoluteMin()
933 */
934 double getAbsoluteXMin() const;
935
936 /** \brief returns the absolute x-axis max of the primary x-axis This is the highest allowed value the the axis min/max.
937 *
938 * \see JKQTPCoordinateAxis::getAbsoluteMax()
939 */
940 double getAbsoluteXMax() const;
941
942 /** \brief returns the absolute y-axis min of the primary y-axis This is the lowest allowed value the the axis min/max.
943 *
944 * \see JKQTPCoordinateAxis::getAbsoluteMin()
945 */
946 double getAbsoluteYMin() const;
947
948 /** \brief returns the absolute y-axis max of the primary y-axis This is the highest allowed value the the axis min/max.
949 *
950 * \see JKQTPCoordinateAxis::getAbsoluteMax()
951 */
952 double getAbsoluteYMax() const;
953
954
955 /** \brief add a new plotter for grid printing mode */
956 void addGridPrintingPlotter(size_t x, size_t y, JKQTBasePlotter* plotter);
957
958 /** \brief clear all additional plotters for grid printing mode */
960
961/**@}*/
962
963
964
965//////////////////////////////////////////////////////////////////////////////////////////////////////////////
966/** @name Drawing Functions */
967/**@{*/
968
969 /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
970 \param painter JKQTPEnhancedPainter to which the plot should be drawn
971 \param rect rectangle to plot into
972 */
973 void draw(JKQTPEnhancedPainter& painter, const QRect& rect);
974
975 /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
976 \param painter JKQTPEnhancedPainter to which the plot should be drawn
977 \param pos where to plot the painter (left-top corner)
978 */
979 void draw(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0));
980
981 /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
982 \param painter JKQTPEnhancedPainter to which the plot should be drawn
983 \param rect rectangle to plot into
984 */
985 void drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect);
986
987 /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
988 \param painter JKQTPEnhancedPainter to which the plot should be drawn
989 \param pos where to plot the painter (left-top corner)
990 */
991 void drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0));
992
993
994 /** \brief emit plotUpdated(), which can be used by e.g. a widget class to update the displayed plot */
995 inline void redrawPlot() { if (emitPlotSignals) emit plotUpdated(); }
996
997 /** \brief controls, whether the signals plotUpdated() are emitted */
999 /** \brief returns, whether the signals plotUpdated() are emitted */
1001 /** \brief returns whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */
1003 /** \brief specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */
1004 void setEmittingSignalsEnabled(bool enabled);
1005
1006
1007 /** \copydoc JKQTBasePlotterStyle::plotBorderTop */
1008 int getPlotBorderTop() const;
1009 /** \copydoc JKQTBasePlotterStyle::plotBorderLeft */
1011 /** \copydoc JKQTBasePlotterStyle::plotBorderBottom */
1013 /** \copydoc JKQTBasePlotterStyle::plotBorderRight */
1015
1016 /** \brief returns whether the maintaining of the data aspect ratio is enabled or disabled \see aspectRatio */
1018 /** \brief returns the data aspect ratio, enforced with setMaintainApsectRatio(true) \see aspectRatio */
1019 double getAspectRatio() const;
1020
1021 /** \brief returns whether the maintaining of the axis aspect ratio is enabled or disabled \see axisAspectRatio */
1023 /** \brief returns the axis aspect ratio, enforced with setMaintainAxisApsectRatio(true) \see axisAspectRatio */
1024 double getAxisAspectRatio() const;
1025 /** \copydoc JKQTBasePlotterStyle::useAntiAliasingForSystem */
1027 /** \copydoc JKQTGraphsBaseStyle::useAntiAliasingForGraphs */
1029 /** \copydoc JKQTBasePlotterStyle::useAntiAliasingForText */
1031 /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
1032 QColor getBackgroundColor() const;
1033 /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
1035 /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
1037 /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
1038 QBrush getBackgroundBrush() const;
1039 /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
1041 /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
1043
1044
1045 /** \copydoc JKQTPKeyStyle::visible */
1046 bool getShowKey() const;
1047 /** \copydoc JKQTPKeyStyle::position */
1049 /** \copydoc JKQTBasePlotterStyle::defaultTextColor */
1050 QColor getDefaultTextColor() const;
1051 /** \copydoc JKQTBasePlotterStyle::defaultFontSize */
1052 double getDefaultTextSize() const;
1053 /** \copydoc JKQTBasePlotterStyle::defaultFontName */
1054 QString getDefaultTextFontName() const;
1055 /** \copydoc fontSizePrintMultiplier */
1056 void setFontSizePrintMultiplier(double __value);
1057 /** \copydoc fontSizePrintMultiplier */
1059 /** \copydoc lineWidthPrintMultiplier */
1060 void setLineWidthPrintMultiplier(double __value);
1061 /** \copydoc lineWidthPrintMultiplier */
1063 /** \copydoc fontSizeMultiplier */
1065 /** \copydoc lineWidthMultiplier */
1067 /** \brief retuns the JKQTPKeyStyle to be used for the main key (extracted from JKQTBasePlotterStyle::keyStyle) */
1069
1070 protected:
1071 /** \brief retuns the JKQTPKeyStyle to be used for the main key (extracted from JKQTBasePlotterStyle::keyStyle) */
1073 friend class JKQTPBaseKey;
1074 friend class JKQTPMainKey;
1075 public:
1076
1077 /** \brief if set \c true (default: \c false ) the JKQTBasePlotter draws colored rectangles to indicate the different regions in the plot (border, axes, ...)
1078 *
1079 *
1080 * \image html debugShowRegionBoxes.png
1081 *
1082 * \see JKQTBasePlotterStyle::debugShowRegionBoxes, enableDebugShowRegionBoxes()
1083 */
1085 /** \brief if set \c true (default: \c false ) the JKQTBasePlotter draws colored rectangles to indicate the extent of text
1086 *
1087 * \image html debugShowTextBoxes.png
1088 *
1089 * \see JKQTBasePlotterStyle::debugShowTextBoxes, enableDebugShowTextBoxes()
1090 */
1092 /** \copydoc JKQTBasePlotterStyle::plotFrameVisible */
1094 /** \copydoc JKQTBasePlotterStyle::plotFrameColor */
1095 QColor getPlotFrameColor() const;
1096 /** \copydoc JKQTBasePlotterStyle::plotFrameWidth */
1097 double getPlotFrameWidth() const;
1098 /** \copydoc JKQTBasePlotterStyle::plotFrameRounding */
1099 double getPlotFrameRounding() const;
1100
1101 /** \copydoc JKQTBasePlotterStyle::plotLabelFontSize */
1102 double getPlotLabelFontSize() const;
1103 /** \copydoc JKQTBasePlotterStyle::plotLabelOffset */
1104 double getPlotLabelOffset() const;
1105 /** \copydoc JKQTBasePlotterStyle::plotLabelTopBorder */
1107 /** \copydoc JKQTBasePlotterStyle::plotLabelFontName */
1108 QString getplotLabelFontName() const;
1109 /** \copydoc JKQTBasePlotterStyle::plotLabelColor */
1110 QColor getPlotLabelColor() const;
1111
1112 /** \copydoc plotLabel */
1113 QString getPlotLabel() const;
1114
1115 /** \copydoc gridPrinting */
1116 void setGridPrinting(bool __value);
1117 /** \copydoc gridPrinting */
1118 bool getGridPrinting() const;
1119 /** \copydoc gridPrintingCurrentX */
1120 void setGridPrintingCurrentX(size_t __value);
1121 /** \copydoc gridPrintingCurrentX */
1123 /** \copydoc gridPrintingCurrentY */
1124 void setGridPrintingCurrentY(size_t __value);
1125 /** \copydoc gridPrintingCurrentY */
1127
1128 /** \brief set the x- and y-positions of this JKQTPlotter in the grid-printing grid
1129 *
1130 * \see setGridPrinting(), addGridPrintingPlotter(), clearGridPrintingPlotters(), setGridPrintingCurrentX(), setGridPrintingCurrentY()
1131 */
1132 void setGridPrintingCurrentPos(size_t x, size_t y);
1133
1134
1135 /** \brief returns the current directory in which to open SaveAs ... dialogs */
1137 /** \brief return the last file format to use in SaveAs ... dialogs */
1138 QString getCurrentFileFormat() const;
1139 /** \brief returns the decimal separator used when exporting data to text files */
1140 QString getCSVdecimalSeparator() const;
1141 /** \brief set the string used to introduce comments in text output when exporting data */
1143
1144 /** \copydoc internalPlotBorderTop */
1145 inline double getInternalPlotBorderTop() const { return this->internalPlotBorderTop; }
1146 /** \copydoc internalPlotBorderLeft */
1147 inline double getInternalPlotBorderLeft() const { return this->internalPlotBorderLeft; }
1148 /** \copydoc internalPlotBorderBottom */
1149 inline double getInternalPlotBorderBottom() const { return this->internalPlotBorderBottom; }
1150 /** \copydoc internalPlotBorderRight */
1151 inline double getInternalPlotBorderRight() const { return this->internalPlotBorderRight; }
1152 /** \copydoc internalPlotWidth */
1153 inline int getPlotWidth() const { return this->internalPlotWidth; }
1154 /** \copydoc internalPlotHeight */
1155 inline int getPlotHeight() const { return this->internalPlotHeight; }
1156
1157 /**@}*/
1158
1159
1160 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1161 /** @name Coordinate Axis Management */
1162 /**@{*/
1163
1164 /** \brief returns the x-axis objet of the plot
1165 *
1166 * \see \ref jkqtplotter_base_grids_baseplotter
1167 */
1169 /** \brief returns the y-axis objet of the plot
1170 *
1171 * \see \ref jkqtplotter_base_grids_baseplotter
1172 */
1174 /** \brief returns the x-axis objet of the plot
1175 *
1176 * \see \ref jkqtplotter_base_grids_baseplotter
1177 */
1179 /** \brief returns the y-axis objet of the plot
1180 *
1181 * \see \ref jkqtplotter_base_grids_baseplotter
1182 */
1184 /** \brief returns whether an x-axis \a axis is registered with the plotter
1185 *
1186 * \note For \a axis \c ==JKQTPPrimaryAxis this function returns always \c true
1187 */
1189 /** \brief returns whether a y-axis \a axis is registered with the plotter
1190 *
1191 * \note For \a axis \c ==JKQTPPrimaryAxis this function returns always \c true
1192 */
1194 /** \brief returns the set of available x-axes (including the primary, if \c true is given as parameter) */
1195 QSet<JKQTPCoordinateAxisRef> getAvailableXAxisRefs(bool includePrimary=false) const;
1196 /** \brief returns the set of available y-axes (including the primary, if \c true is given as parameter) */
1197 QSet<JKQTPCoordinateAxisRef> getAvailableYAxisRefs(bool includePrimary=false) const;
1198 /** \brief returns all available x-axes */
1199 QMap<JKQTPCoordinateAxisRef, JKQTPHorizontalAxisBase*> getXAxes(bool includePrimary=true);
1200 /** \brief returns all available y-axes */
1201 QMap<JKQTPCoordinateAxisRef, JKQTPVerticalAxisBase*> getYAxes(bool includePrimary=true);
1202 /** \brief returns all available x- or y-axes */
1203 QList<JKQTPCoordinateAxis*> getAxes(bool includePrimaries=true);
1204 /** \brief returns all available x- or y-axes */
1205 QList<const JKQTPCoordinateAxis*> getAxes(bool includePrimaries=true) const;
1206
1207 /** \brief adds a secondary x-axis
1208 *
1209 * \param axis the JKQTPHorizontalAxisBase object to add
1210 * \returns a reference to this axis
1211 *
1212 * Usage is simple:
1213 * \code
1214 * // construct a new x-axis-object
1215 * JKQTPHorizontalAxisBase* secXAxis=new JKQTPHorizontalAxis(plot.getPlotter(), JKQTPPrimaryAxis)
1216 * // add it to the plot
1217 * auto xAxisRef2=plot.getPlotter()->addSecondaryXAxis(secXAxis);
1218 * // ... now you can access it:
1219 * plot.getXAxis(xAxisRef2)->setShowZeroAxis(false);
1220 * // ... and use it for graphs:
1221 * graph2->setXAxis(xAxisRef2);
1222 * \endcode
1223 *
1224 *
1225 * Here is an example output:
1226 *
1227 * \image html JKQTBasePlotter_addSecondaryXAxis.png
1228 *
1229 * \see \ref jkqtplotter_base_grids_baseplotter_secondaryaxes , \subpage JKQTPlotterSecondaryAxes
1230 */
1232 /** \brief adds a secondary y-axis
1233 *
1234 * \param axis the JKQTPVerticalAxisBase object to add
1235 * \returns a reference to this axis
1236 *
1237 * Usage is simple:
1238 * \code
1239 * // construct a new y-axis-object
1240 * JKQTPVerticalAxisBase* secYAxis=new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis)
1241 * // add it to the plot
1242 * auto yAxisRef2=plot.getPlotter()->addSecondaryYAxis(secYAxis);
1243 * // ... now you can access it:
1244 * plot.getYAxis(yAxisRef2)->setShowZeroAxis(false);
1245 * // ... and use it for graphs:
1246 * graph2->setYAxis(yAxisRef2);
1247 * \endcode
1248 *
1249 * Here is an example output:
1250 *
1251 * \image html JKQTBasePlotter_addSecondaryYAxis.png
1252 *
1253 * \see \ref jkqtplotter_base_grids_baseplotter_secondaryaxes , \subpage JKQTPlotterSecondaryAxes
1254 */
1256 /** \brief updates the secondary axes
1257 *
1258 * The plot may contain (in addition to its primary axes) also secondary axes, that depend in their
1259 * scaling (min,max, ...) on the primmary axes of the plot. This function updates/recalculates the
1260 * scaling of these axes.
1261 */
1263
1264
1265 /** \brief takes a new axis range \a xminn ... \a xmaxx and \a yminn ... \a ymaxx and corrects the values to match the currently set axisAspectRatio
1266 *
1267 * This function is used by setXY(), setX(), setY().
1268 *
1269 * \see axisAspectRatio, setXY(), setX(), setY()
1270 */
1271 void correctXYRangeForAspectRatio(double &xminn, double &xmaxx, double &yminn, double &ymaxx) const;
1272
1273/**@}*/
1274
1275
1276//////////////////////////////////////////////////////////////////////////////////////////////////////////////
1277/** @name Key Management Management */
1278/**@{*/
1279 /** \brief retuns the main key object */
1281 /** \brief retuns the main key object */
1282 const JKQTPBaseKey* getMainKey() const;
1283/**@}*/
1284
1285
1286//////////////////////////////////////////////////////////////////////////////////////////////////////////////
1287/** @name QActions Management */
1288/**@{*/
1289
1290 /** \copydoc actSavePlot */
1291 QAction* getActionSavePlot() const;
1292 /** \copydoc actSaveData */
1293 QAction* getActionSaveData() const;
1294 /** \copydoc actCopyData */
1295 QAction* getActionCopyData() const;
1296 /** \copydoc actCopyPixelImage */
1297 QAction* getActionCopyPixelImage() const;
1298 /** \copydoc actCopyMatlab */
1299 QAction* getActionCopyMatlab() const;
1300#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
1301 /** \copydoc actSavePDF */
1302 QAction* getActionSavePDF() const;
1303 /** \copydoc actSaveSVG */
1304 QAction* getActionSaveSVG() const;
1305 /** \copydoc actPrint */
1306 QAction* getActionPrint() const;
1307#endif
1308 /** \copydoc actSavePix */
1309 QAction* getActionSavePix() const;
1310 /** \copydoc actSaveCSV */
1311 QAction* getActionSaveCSV() const;
1312 /** \copydoc actZoomAll */
1313 QAction* getActionZoomAll() const;
1314 /** \copydoc actZoomIn */
1315 QAction* getActionZoomIn() const;
1316 /** \copydoc actZoomOut */
1317 QAction *getActionZoomOut() const;
1318 /** \copydoc actShowPlotData */
1319 QAction *getActionShowPlotData() const;
1320 /** \copydoc lstAdditionalPlotterActions */
1322
1323 /** \brief this function registers additional actions to lstAdditionalPlotterActions, which are displayed in the context-menu */
1324 void registerAdditionalAction(const QString& key, QAction* act);
1325 /** \brief this function deregisters an additional action, previously added with registerAdditionalAction()
1326 *
1327 * \see registerAdditionalAction()
1328 */
1329 void deregisterAdditionalAction(QAction* act);
1330
1331
1332
1333/**@}*/
1334
1335
1336
1337//////////////////////////////////////////////////////////////////////////////////////////////////////////////
1338/** @name Master/Slave Plot Synchronization */
1339/**@{*/
1340
1341 /** \copydoc masterSynchronizeWidth */
1343 /** \copydoc masterSynchronizeHeight */
1345
1346
1347 /** \brief denotes, which axes to synchronize in synchronizeToMaster() */
1349 sdXAxis, /**< \brief x-axis only */
1350 sdYAxis, /**< \brief y-axis only */
1351 sdXYAxes /**< \brief x- and y-axis */
1353
1354 /*! \brief synchronize the plot borders (and zooming) with a given plotter (master --> slave/this)
1355
1356 This function allows two plotters to draw a graph with exactly the same height or width
1357 as in another graph. For example if you want to have two plotters which are positioned one
1358 above the other (and have the same widget widths, which could be guaranteed by a QLayout)
1359 you may want to make sure that their plotWidth s are always the same. In this case call
1360 \code plotter2->synchronizeToMaster(plotter1, sdXAxis, true) \endcode of the lower plotter \c plotter2 .
1361 Now whenever the size of plotter1 changes, also plotter2 is redrawn with the changed
1362 borders.
1363
1364 \param master the plotter widget to synchronize to
1365 \param synchronizeDirection direction in which to synchronize
1366 \param synchronizeAxisLength do you want the axis length to be synchronized?
1367 \param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave
1368 \param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master
1369
1370 \see synchronizeXToMaster(), synchronizeYToMaster(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
1371 */
1372 void synchronizeToMaster(JKQTBasePlotter* master, SynchronizationDirection synchronizeDirection, bool synchronizeAxisLength=true, bool synchronizeZoomingMasterToSlave=true, bool synchronizeZoomingSlaveToMaster=true);
1373
1374 /*! \brief synchronize the plot x-axis width (and x-zooming) with a given master plotter (master --> slave/this)
1375
1376 \param master the plotter widget to synchronize to
1377 \param synchronizeAxisLength do you want the axis length to be synchronized?
1378 \param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave
1379 \param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master
1380
1381 \note This is a short-cut to synchronizeToMaster() with \c synchronizeDirection=csXAxis
1382 \see synchronizeToMaster(), synchronizeYToMaster(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
1383 */
1384 void synchronizeXToMaster(JKQTBasePlotter* master, bool synchronizeAxisLength=true, bool synchronizeZoomingMasterToSlave=true, bool synchronizeZoomingSlaveToMaster=true);
1385
1386 /*! \brief synchronize the plot y-axis height (and y-zooming) with a given master plotter (master --> slave/this)
1387
1388 \param master the plotter widget to synchronize to
1389 \param synchronizeAxisLength do you want the axis length to be synchronized?
1390 \param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave
1391 \param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master
1392
1393 \note This is a short-cut to synchronizeToMaster() with \c synchronizeDirection=csXAxis
1394 \see synchronizeToMaster(), synchronizeXToMaster(), \ref JKQTBASEPLOTTER_SYNCMULTIPLOT
1395 */
1396 void synchronizeYToMaster(JKQTBasePlotter* master, bool synchronizeAxisLength=true, bool synchronizeZoomingMasterToSlave=true, bool synchronizeZoomingSlaveToMaster=true);
1397
1398 /** \brief switches any synchronization off, that has been created by synchronizeToMaster() */
1399 void resetMasterSynchronization(SynchronizationDirection synchronizeDirection=sdXYAxes);
1400
1401/**@}*/
1402
1403
1404
1405
1406//////////////////////////////////////////////////////////////////////////////////////////////////////////////
1407/** @name Utilities: (math-markup) Text Sizing */
1408/**@{*/
1409
1410 /** \brief internal tool class for text-sizess in a plot key
1411 * \ingroup jkqtpplottersupprt
1412 * \internal */
1414 explicit textSizeKey(const QFont& f, const QString& text, QPaintDevice *pd);
1415 explicit textSizeKey(const QString& fontName, double fontSize, const QString& text, QPaintDevice *pd);
1416 QString text;
1417 QFont f;
1418 int ldpiX, ldpiY, pdpiX, pdpiY;
1419
1420 bool operator==(const textSizeKey& other) const;
1421 };
1422 /** \brief calculates a JKQTMathTextNodeSize for the given string \a text if it would be drawn on \a painter with font \a fm
1423 * \internal
1424 */
1425 JKQTMathTextNodeSize getTextSizeDetail(const QFont &fm, const QString& text, QPainter& painter);
1426 /** \brief calculates a JKQTMathTextNodeSize for the given string \a text if it would be drawn on \a painter with font \a fontName
1427 * \internal
1428 */
1429 JKQTMathTextNodeSize getTextSizeDetail(const QString& fontName, double fontSize, const QString& text, QPainter &painter);
1430 /** \brief calculates a text-size details for the given string \a text if it would be drawn on \a painter with font \a fontName and font size \a fontSize
1431 * \internal
1432 */
1433 void getTextSizeDetail(const QString& fontName, double fontSize, const QString& text, QPainter &painter, double& width, double& ascent, double& descent, double& strikeoutPos);
1434 /** \brief calculates a text-size details for the given string \a text if it would be drawn on \a painter with font \a fm
1435 * \internal
1436 */
1437 void getTextSizeDetail(const QFont& fm, const QString& text, QPainter &painter, double& width, double& ascent, double& descent, double& strikeoutPos);
1438 /** \brief calculates a size of the given string \a text if it would be drawn on \a painter with font \a fm
1439 * \internal
1440 */
1441 QSizeF getTextSizeSize(const QFont &fm, const QString& text, QPainter& painter);
1442 /** \brief calculates a size of the given string \a text if it would be drawn on \a painter with font \a fontName and font size \a fontSize
1443 * \internal
1444 */
1445 QSizeF getTextSizeSize(const QString& fontName, double fontSize, const QString& text, QPainter &painter);
1446 /** \brief returns the internal JKQTMathText, used to render text with LaTeX markup */
1448 /** \brief returns the internal JKQTMathText, used to render text with LaTeX markup */
1450/**@}*/
1451
1452
1453
1454
1455
1456//////////////////////////////////////////////////////////////////////////////////////////////////////////////
1457/** @name Plot Data Export */
1458/**@{*/
1459public Q_SLOTS:
1460
1461 /** \brief save the data used for the current plot. The file format is extracted from the file extension (csv, ...)
1462 *
1463 * \param filename the filename to save to, if empty a file save dialog is displayed
1464 * \param format The parameter \a format specifies the export format. if it is empty the format will be choosen according to the file extension, or
1465 * if \a filename is also empty the format will be choosen according to what is selected in the file selection dialog.
1466 * See below for a listing of supported values.
1467 * \returns returns \c true if the data was exported successfully.
1468 *
1469 * These values are supported for \a format (if \a format is not provided, the function tries to guess it from the file extensions liste below):
1470 * - \c "csv", Comma Separated Values, dot as decimal separator (see also <a href="https://en.wikipedia.org/wiki/Comma-separated_values">https://en.wikipedia.org/wiki/Comma-separated_values</a>, extensions: \c *.csv , \c *.dat , see JKQTBasePlotter::saveAsCSV()
1471 * - \c "tab" Tab Separated Values, dot as decimal separator, extensions: \c *.txt , see JKQTBasePlotter::saveAsTabSV()
1472 * - \c "sem" or \c "ssv", Semicolon Separated Values, dot as decimal separator, extensions: \c *.sem , \c *.ssv , see JKQTBasePlotter::saveAsSemicolonSV()
1473 * - \c "gex", Semicolon Separated Values for German Excel, i.e. comma as decimal separator, extensions: \c *.gex , see JKQTBasePlotter::saveAsGerExcelCSV()
1474 * - \c "slk" or \c "sylk" , SYmbolik LinK (SYLK) spreadsheet (see <a href="https://en.wikipedia.org/wiki/Symbolic_Link_(SYLK)">https://en.wikipedia.org/wiki/Symbolic_Link_(SYLK)</a> ), extensions: \c *.slk , \c *.sylk , see JKQTBasePlotter::saveAsSYLK()
1475 * - \c "dif", Data Interchange Format (see <a href="https://en.wikipedia.org/wiki/Data_Interchange_Format">https://en.wikipedia.org/wiki/Data_Interchange_Format</a>), extensions: \c *.dif , see JKQTBasePlotter::saveAsDIF()
1476 * - \c "m", Matlab Script, extensions: \c *.m , see JKQTBasePlotter::saveAsMatlab()
1477 * .
1478 *
1479 * In addition you can use the custom exporters implemented as JKQTPSaveDataAdapter and registered using JKQTBasePlotter::registerSaveDataAdapter().
1480 * For these you need to use \a format <code>= "customN"</code>, where N is the index of the exporter in the list of registered exporters.
1481 */
1482 bool saveData(const QString& filename=QString(""), const QString& format=QString(""));
1483 /** \brief copy the data used for the current plot to the clipboard
1484 *
1485 * copies data as tab separated data with the system-decimal point.
1486 */
1487 void copyData();
1488 /** \brief copy the data used for the current plot to the clipboard as a Matlab script
1489 *
1490 * example output:
1491 * \code
1492 * % data from columne 1 ('x')
1493 * x = [ 0 0.251327 0.502655 ... ];
1494 *
1495 * % data from columne 2 ('y')
1496 * y = [ 0 0.24869 0.481754 ... ];
1497 * \endcode
1498 *
1499 * \see saveAsMatlab()
1500 */
1502 /** \brief save the current plot data as a Comma Separated Values (CSV) file
1503 *
1504 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1505 *
1506 *
1507 * This method uses JKQTBasePlotterStyle::CSVdecimalSeparator as decimal separator and
1508 * JKQTBasePlotterStyle::CSVcommentInitializer as comment initializer!
1509 */
1510 void saveAsCSV(const QString& filename=QString(""));
1511
1512 /** \brief save the current plot data as a Semicolon Separated Values (SSV) file
1513 *
1514 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1515 *
1516 * example output:
1517 * \code
1518 * # x, y
1519 * 0; 0
1520 * 0.251327; 0.24869
1521 * 0.502655; 0.481754
1522 * ...
1523 * \endcode
1524 *
1525 * This method uses JKQTBasePlotterStyle::CSVdecimalSeparator as decimal separator and
1526 * JKQTBasePlotterStyle::CSVcommentInitializer as comment initializer!
1527 */
1528 void saveAsSemicolonSV(const QString& filename=QString(""));
1529
1530 /** \brief save the current plot data as a Tabulator Separated Values (CSV) file
1531 *
1532 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1533 *
1534 *
1535 * example output:
1536 * \code
1537 * # x y
1538 * 0 0
1539 * 0.251327 0.24869
1540 * 0.502655 0.481754
1541 * ...
1542 * \endcode
1543 *
1544 * This method uses JKQTBasePlotterStyle::CSVdecimalSeparator as decimal separator and
1545 * JKQTBasePlotterStyle::CSVcommentInitializer as comment initializer!
1546 *
1547 * \see saveData()
1548 */
1549 void saveAsTabSV(const QString& filename=QString(""));
1550
1551 /** \brief save the current plot data as a Data Interchange Format file (see <a href="https://en.wikipedia.org/wiki/Data_Interchange_Format">https://en.wikipedia.org/wiki/Data_Interchange_Format</a>).
1552 *
1553 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1554 *
1555 * \see saveData()
1556 */
1557 void saveAsDIF(const QString& filename=QString(""));
1558
1559 /** \brief save the current plot data as a SYmbolik LinK (SYLK) spreadsheet file (see <a href="https://en.wikipedia.org/wiki/Symbolic_Link_(SYLK)">https://en.wikipedia.org/wiki/Symbolic_Link_(SYLK)</a> )
1560 *
1561 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1562 *
1563 * \see saveData()
1564 */
1565 void saveAsSYLK(const QString& filename=QString(""));
1566
1567 /** \brief save the current plot data as a Matlab Script
1568 *
1569 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1570 *
1571 * example output:
1572 * \code
1573 * % data from columne 1 ('x')
1574 * x = [ 0 0.251327 0.502655 ... ];
1575 *
1576 * % data from columne 2 ('y')
1577 * y = [ 0 0.24869 0.481754 ... ];
1578 * \endcode
1579 *
1580 * \see copyDataMatlab(), saveData()
1581 */
1582 void saveAsMatlab(const QString& filename=QString(""));
1583
1584 /** \brief save the current plot data as a Semicolon Separated Values (CSV) file for german Excel, i.e. with comma as decimal separator
1585 *
1586 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1587 *
1588 * example output:
1589 * \code
1590 * # x, y
1591 * 0, 0
1592 * 0,251327; 0,24869
1593 * 0,502655; 0,481754
1594 * ...
1595 * \endcode
1596 *
1597 * \see saveData(), saveAsSemicolonSV()
1598 */
1599 void saveAsGerExcelCSV(const QString& filename=QString(""));
1600
1601 public:
1602 /** \brief save the current plot data as a Comma Separated Values (CSV) file
1603 *
1604 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1605 * \param decimalSeparator decimal separator for outpu
1606 * \param commentInitializer line-start for comment lines
1607 *
1608 * example output:
1609 * \code
1610 * # x, y
1611 * 0, 0
1612 * 0.251327, 0.24869
1613 * 0.502655, 0.481754
1614 * ...
1615 * \endcode
1616 *
1617 * This method uses JKQTBasePlotterStyle::CSVdecimalSeparator as decimal separator and
1618 * JKQTBasePlotterStyle::CSVcommentInitializer as comment initializer!
1619 */
1620 void saveAsCSV(const QString& filename, const QString& decimalSeparator, const QString& commentInitializer);
1621
1622 /** \brief save the current plot data as a Semicolon Separated Values (SSV) file
1623 *
1624 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1625 * \param decimalSeparator decimal separator for outpu
1626 * \param commentInitializer line-start for comment lines
1627 *
1628 * example output for <code>saveAsSemicolonSV(filename, ",","#")</code>:
1629 * \code
1630 * # x, y
1631 * 0, 0
1632 * 0,251327; 0,24869
1633 * 0,502655; 0,481754
1634 * ...
1635 * \endcode
1636 */
1637 void saveAsSemicolonSV(const QString& filename, const QString& decimalSeparator, const QString& commentInitializer);
1638 /** \brief save the current plot data as a Tabulator Separated Values (CSV) file
1639 *
1640 * \param filename the file to save to, if \a filename is empty, a file open dialog will be shown
1641 * \param decimalSeparator decimal separator for outpu
1642 * \param commentInitializer line-start for comment lines
1643 *
1644 * example output for <code>saveAsTabSV(filename, ",","#")</code>:
1645 * \code
1646 * # x y
1647 * 0 0
1648 * 0,251327 0,24869
1649 * 0,502655 0,481754
1650 * ...
1651 * \endcode
1652 */
1653 void saveAsTabSV(const QString& filename, const QString& decimalSeparator, const QString& commentInitializer);
1654
1655/**@}*/
1656
1657//////////////////////////////////////////////////////////////////////////////////////////////////////////////
1658/** @name Saving/Exporting Plots as Image/Vector Files */
1659/**@{*/
1660public Q_SLOTS:
1661
1662 /** \brief save the current plot as a pixel image image (PNG ...), if filename is empty a file selection dialog is displayed
1663 *
1664 * \param filename name of the stored file, if no \a outputFormat is given, the file format is deduced by the file extension in \a filename
1665 * \param displayPreview if \c true a dialog is shown that allows to modify the generated output (zoo, scaling, ...)
1666 * \param outputFormat specify the file format for the generated file
1667 * \param outputSizeIncrease if given, the size of the generated pixel image is increased by this number of pixels in addition to the required space
1668 * \return returns \c true on success
1669 *
1670 * This function may generate any pixel-graphics format, supported by Qt and listed in <a href="https://doc.qt.io/qt-6/qimagewriter.html"><code>QImageWriter::supportedImageFormats()</code></a>.
1671 * The parameters are comparable to the standard Qt functions like <a href="https://doc.qt.io/qt-6/qimage.html#save"><code>QImage::save()</code></a>, which is also used internally.
1672 *
1673 * \see grabPixelImage(), copyPixelImage()
1674 */
1675 bool saveAsPixelImage(const QString& filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray(), const QSize& outputSizeIncrease=QSize(0,0));
1676
1677 /** \brief returns a rendering of the current plot as a QImage (pixel image) with the given size
1678 *
1679 * \see saveAsPixelImage(), copyPixelImage()
1680 */
1681 QImage grabPixelImage(QSize size=QSize(), bool showPreview=false);
1682 /** \brief copy the current plot as a pixel+svg image to the clipboard */
1683 void copyPixelImage(bool showPreview=true);
1684
1685#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
1686 /** \brief save the current plot as a SVG file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed
1687 *
1688 * \param filename the filename to save to, if empty a file save dialog is displayed
1689 * \param displayPreview if \c true, a save/print-preview dialog is displayed that allows to make some modifications to the generated image, otherwise the image is saved with default settings.
1690 * \return Returns \c true if the file was save successfully
1691 *
1692 * \note Exporting to SVG requires QPrinter-support, if it is not available on your platform, this function will not be available either!
1693 */
1694 bool saveAsSVG(const QString& filename=QString(""), bool displayPreview=true);
1695
1696 /** \brief save the current plot as a PDF file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed
1697 *
1698 * \param filename the filename to save to, if empty a file save dialog is displayed
1699 * \param displayPreview if \c true, a save/print-preview dialog is displayed that allows to make some modifications to the generated image, otherwise the image is saved with default settings.
1700 * \return Returns \c true if the file was save successfully
1701 *
1702 * \note Exporting to PDF requires QPrinter-support, if it is not available on your platform, this function will not be available either!
1703 */
1704 bool saveAsPDF(const QString& filename=QString(""), bool displayPreview=true);
1705#endif
1706
1707 /** \brief save the current plot as an image file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed.
1708 * The image format is extracted from the file extension (jpeg, tiff, png, pdf, ...)
1709 *
1710 * \param filename the filename to save to, if empty a file save dialog is displayed
1711 * \param displayPreview if \c true, a save/print-preview dialog is displayed that allows to make some modifications to the generated image, otherwise the image is saved with default settings.
1712 * \return Returns \c true if the file was save successfully
1713 *
1714 * This function is comparable to saveAsPixelImage(), but it allows to save into any graphics format, including SVG and PF (if printer-support is compiled into the library).
1715 * Also it may use the custom exporters implemented as JKQTPPaintDeviceAdapter and registered via JKQTBasePlotter::registerPaintDeviceAdapter().
1716 *
1717 * \see grabPixelImage(), copyPixelImage(), saveAsPixelImage(), JKQTBasePlotter::registerPaintDeviceAdapter(), JKQTPPaintDeviceAdapter
1718 */
1719 bool saveImage(const QString& filename=QString(""), bool displayPreview=true);
1720
1721 Q_SIGNALS:
1722 /** \brief emitted just before exporting the current plot as image, or just before the export preview dialog is shown
1723 *
1724 * This signal can be used to e.g. modify the plotter settings before an export.
1725 *
1726 * \see afterExporting(), beforePrinting(), afterPrinting()
1727 */
1729
1730 /** \brief emitted just before exporting the current plot as image, or just before the export preview dialog is shown
1731 *
1732 * This signal can be used to e.g. modify the plotter settings after an export.
1733 *
1734 * \see beforeExporting(), beforePrinting(), afterPrinting()
1735 */
1737
1738
1739/**@}*/
1740
1741
1742 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1743/** @name Print Support */
1744/**@{*/
1745public Q_SLOTS:
1746
1747#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
1748 /** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed
1749 *
1750 * \note This function is only available on platforms with QPrinter support!
1751 */
1752 void print(QPrinter* printer=nullptr, bool displayPreview=true);
1753#endif
1754 Q_SIGNALS:
1755 /** \brief emitted just before Printing the current plot as image, or just before the print preview dialog is shown
1756 *
1757 * This signal can be used to e.g. modify the plotter settings before a print.
1758 *
1759 * \see afterPrinting(), beforeExporting(), afterExporting()
1760 */
1762
1763 /** \brief emitted just before Printing the current plot as image, or just before the print preview dialog is shown
1764 *
1765 * This signal can be used to e.g. modify the plotter settings after a print.
1766 *
1767 * \see beforePrinting(), beforeExporting(), afterExporting()
1768 */
1770
1771/**@}*/
1772
1773 Q_SIGNALS:
1774 /** \brief signal: emitted whenever the user selects a new x-y zoom range (in the major axes, e.g. setX(), setY(), setXY(), zoomToFit()... )
1775 *
1776 * \param newxmin start of the selected x-range (in plot coordinates)
1777 * \param newxmax end of the selected x-range (in plot coordinates)
1778 * \param newymin start of the selected x-range (in plot coordinates)
1779 * \param newymax end of the selected x-range (in plot coordinates)
1780 * \param sender JKQTPlotter sending this event
1781 *
1782 */
1783 void zoomChangedLocally(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender);
1784
1785 /** \brief emitted when the plot has to be updated */
1787
1788 /** \brief emitted when the plot scaling had to be recalculated */
1790
1791 /** \brief emitted before the plot scaling has been recalculated */
1793
1794
1795
1796 public Q_SLOTS:
1797
1798
1799 /** \brief sets the width of the plot widget
1800 *
1801 * \image html plot_widget_orientation.png
1802 *
1803 * \see setWidgetSize(), \ref jkqtplotter_base_plotsize
1804 */
1805 void setWidgetWidth(int wid);
1806
1807 /** \brief resize the plot
1808 *
1809 * \image html plot_widget_orientation.png
1810 *
1811 * \see \ref jkqtplotter_base_plotsize
1812 */
1813 void setWidgetSize(int width, int height);
1814 /** \brief resize the plot
1815 *
1816 * \image html plot_widget_orientation.png
1817 *
1818 * \see \ref jkqtplotter_base_plotsize
1819 */
1820 void setWidgetSize(QSize size);
1821
1822 /** \brief sets the width of the plot widget
1823 *
1824 * \image html plot_widget_orientation.png
1825 *
1826 * \see setWidgetSize(), \ref jkqtplotter_base_plotsize
1827 */
1828 void setWidgetHeight(int heigh);
1829
1830 /** \brief sets the borders of the plot
1831 *
1832 * \image html plot_widget_orientation.png
1833 *
1834 * \see \ref jkqtplotter_base_plotsize
1835 */
1836 void setPlotBorder(int left, int right, int top, int bottom);
1837
1838 /** \brief sets the left border of the plot
1839 *
1840 * \image html plot_widget_orientation.png
1841 *
1842 * \see \ref jkqtplotter_base_plotsize
1843 */
1844 void setPlotBorderLeft(int left);
1845
1846 /** \brief sets the right border of the plot
1847 *
1848 * \image html plot_widget_orientation.png
1849 *
1850 * \see \ref jkqtplotter_base_plotsize
1851 */
1852 void setPlotBorderRight(int right);
1853
1854 /** \brief sets the top border of the plot
1855 *
1856 * \image html plot_widget_orientation.png
1857 *
1858 * \see \ref jkqtplotter_base_plotsize
1859 */
1860 void setPlotBorderTop(int top);
1861
1862 /** \brief sets the bottom border of the plot
1863 *
1864 * \image html plot_widget_orientation.png
1865 *
1866 * \see \ref jkqtplotter_base_plotsize
1867 */
1868 void setPlotBorderBottom(int bottom);
1869
1870 /** \brief sets the x-range of the plot (minimum and maximum x-value on the x-axis)
1871 *
1872 * \param xminn absolute minimum of x-axis
1873 * \param xmaxx absolute maximum of x-axis
1874 * \param affectsSecondaryAxes if \c true, the secondary axes are affectedtoo, by using a relative zooming scheme,
1875 * i.e. if a major axis range shrinks by 50%, also the secondary ranges shrink by 50%
1876 * [default: \c false]
1877 *
1878 * \note You cannot expand the x-range outside the absolute x-range set e.g. by setAbsoluteX()!
1879 * Also the range will be limited to possible values (e.g. to positive values if you use
1880 * logarithmic axes).
1881 *
1882 * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals
1883 * is activated at the moment (e.g. using setEmittingSignalsEnabled() ).
1884 *
1885 * \see setY(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTPlotter::setY()
1886 */
1887 void setX(double xminn, double xmaxx, bool affectsSecondaryAxes=false);
1888
1889 /** \brief sets the y-range of the plot (minimum and maximum y-value on the y-axis)
1890 *
1891 * \param yminn absolute minimum of y-axis
1892 * \param ymaxx absolute maximum of y-axis
1893 * \param affectsSecondaryAxes if \c true, the secondary axes are affectedtoo, by using a relative zooming scheme,
1894 * i.e. if a major axis range shrinks by 50%, also the secondary ranges shrink by 50%
1895 * [default: \c false]
1896 *
1897 * \note You cannot expand the y-range outside the absolute y-range set e.g. by setAbsoluteY()!
1898 * Also the range will be limited to possible values (e.g. to positive values if you use
1899 * logarithmic axes).
1900 *
1901 * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals
1902 * is activated at the moment (e.g. using setEmittingSignalsEnabled() ).
1903 *
1904 * \see setX(), setXY(), zoomToFit(), setAbsoluteXY(), JKQTPlotter::setX()
1905 */
1906 void setY(double yminn, double ymaxx, bool affectsSecondaryAxes=false);
1907
1908 /** \brief sets the x- and y-range of the plot (minimum and maximum values on the x-/y-axis)
1909 *
1910 * \param xminn absolute minimum of x-axis
1911 * \param xmaxx absolute maximum of x-axis
1912 * \param yminn absolute minimum of y-axis
1913 * \param ymaxx absolute maximum of y-axis
1914 * \param affectsSecondaryAxes if \c true, the secondary axes are affectedtoo, by using a relative zooming scheme,
1915 * i.e. if a major axis range shrinks by 50%, also the secondary ranges shrink by 50%
1916 * [default: \c false]
1917 *
1918 * \note You cannot expand the ranges outside the absolute ranges set e.g. by setAbsoluteXY()!
1919 * Also the range will be limited to possible values (e.g. to positive values if you use
1920 * logarithmic axes).
1921 *
1922 * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals
1923 * is activated at the moment (e.g. using setEmittingSignalsEnabled() ).
1924 *
1925 * \see setX(), setX(), zoomToFit(), setAbsoluteXY()
1926 */
1927 void setXY(double xminn, double xmaxx, double yminn, double ymaxx, bool affectsSecondaryAxes=false);
1928
1929
1930 /** \copydoc setXY()
1931 * \deprecated The function JKQTBasePlotter::zoom() is deprecated and will be removed in future version, use JKQTBasePlotter::setXY() instead!
1932 */
1933 inline void zoom(double xminn, double xmaxx, double yminn, double ymaxx, bool affectsSecondaryAxes=false) {
1934 setXY(xminn, xmaxx, yminn, ymaxx, affectsSecondaryAxes);
1935 }
1936
1937 /** \brief sets absolutely limiting x-range of the plot
1938 *
1939 * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function.
1940 * This is implemented by calling JKQTPCoordinateAxis::setAbsoluteRange() for the major x-axes!
1941 *
1942 * \param xminn absolute minimum of x-axis
1943 * \param xmaxx absolute maximum of x-axis
1944 *
1945 * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents!
1946 *
1947 * \see setAbsoluteXY(), setAbsoluteY(), JKQTPCoordinateAxis::setAbsoluteRange()
1948 */
1949 void setAbsoluteX(double xminn, double xmaxx);
1950
1951 /** \brief sets absolute minimum and maximum y-value to plot
1952 *
1953 * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function.
1954 * This is implemented by calling JKQTPCoordinateAxis::setAbsoluteRange() for the major y-axes!
1955 *
1956 * \param yminn absolute minimum of y-axis
1957 * \param ymaxx absolute maximum of y-axis
1958 *
1959 * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents!
1960 *
1961 * \see setAbsoluteXY(), setAbsoluteX(), JKQTPCoordinateAxis::setAbsoluteRange()
1962 */
1963 void setAbsoluteY(double yminn, double ymaxx);
1964
1965 /** \brief sets absolutely limiting x- and y-range of the plot
1966 *
1967 * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function.
1968 * This is implemented by calling JKQTPCoordinateAxis::setAbsoluteRange() for the major axes!
1969 *
1970 * \param xminn absolute minimum of x-axis
1971 * \param xmaxx absolute maximum of x-axis
1972 * \param yminn absolute minimum of y-axis
1973 * \param ymaxx absolute maximum of y-axis
1974 *
1975 * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents!
1976 *
1977 * \see setAbsoluteX(), setAbsoluteY(), JKQTPCoordinateAxis::setAbsoluteRange()
1978 */
1979 void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx);
1980
1981
1982
1983 /** \brief sets whether the major grid lines of the major axes are shown
1984 *
1985 * \image html jkqtplotter_gridvisible.png "Grid visible"
1986 * \image html jkqtplotter_gridinvisible.png "Grid invisible"
1987 *
1988 * \see JKQTPCoordinateAxis::setDrawGrid() and JKQTPGridStyle::enabled in JKQTPCoordinateAxisStyle::majorGridStyle
1989 */
1990 void setGrid(bool val);
1991
1992 /** \brief sets the color of all major grid lines (of the major x- and y-axis)
1993 *
1994 * \see JKQTPCoordinateAxis::setGridColor() and JKQTPGridStyle::lineColor in JKQTPCoordinateAxisStyle::majorGridStyle
1995 * */
1996 void setGridColor(QColor color);
1997
1998 /** \brief sets the color of all minor grid lines (of the major x- and y-axis)
1999 *
2000 * \see JKQTPCoordinateAxis::setMinorGridColor() and JKQTPGridStyle::lineColor in JKQTPCoordinateAxisStyle::minorGridStyle
2001 * */
2002 void setMinorGridColor(QColor color);
2003
2004 /** \brief sets the width of all Major grid lines
2005 *
2006 * \see JKQTPCoordinateAxis::setGridWidth() and JKQTPGridStyle::lineWidth in JKQTPCoordinateAxisStyle::majorGridStyle
2007 * */
2008 void setGridWidth(double __value);
2009
2010 /** \brief sets the width of all minor grid lines
2011 *
2012 * \see JKQTPCoordinateAxis::setMinorGridWidth() and JKQTPGridStyle::lineWidth in JKQTPCoordinateAxisStyle::minorGridStyle
2013 */
2014 void setMinorGridWidth(double __value);
2015
2016 /** \brief sets the style of all Major grid lines
2017 *
2018 * \see JKQTPCoordinateAxis::setGridStyle() and JKQTPGridStyle::lineStyle in JKQTPCoordinateAxisStyle::majorGridStyle
2019 * */
2020 void setGridStyle(Qt::PenStyle __value);
2021
2022 /** \brief sets the style of all minor grid lines
2023 *
2024 * \see JKQTPCoordinateAxis::setMinorGridStyle() and JKQTPGridStyle::lineStyle in JKQTPCoordinateAxisStyle::minorGridStyle
2025 * */
2026 void setMinorGridStyle(Qt::PenStyle __value);
2027
2028
2029 /** \brief switches the visibility of the zero-axes associated with the major x- and y-axis
2030 *
2031 * \param showX indicates whether to show the zero-axis associated with the x-axis (i.e. x==0 or the vertical zero-axis)
2032 * \param showY indicates whether to show the zero-axis associated with the y-axis (i.e. y==0 or the horizontal zero-axis)
2033 *
2034 * \see JKQTPCoordinateAxis::showZeroAxis() and JKQTPCoordinateAxisStyle::showZeroAxis
2035 * */
2036 void setShowZeroAxes(bool showX, bool showY);
2037 /** \brief switches the visibility of the zero-axes associated with the major x- and y-axis
2038 *
2039 * \param showXY indicates whether to show the zero-axis associated with the x- <ul>and</ul> y-axis
2040 *
2041 * \see JKQTPCoordinateAxis::showZeroAxis() and JKQTPCoordinateAxisStyle::showZeroAxis
2042 * */
2043 void setShowZeroAxes(bool showXY);
2044
2045
2046 /** \brief this method zooms the graph so that all plotted datapoints are visible.
2047 *
2048 * \param zoomX if set \c true (default) zooms the x axis
2049 * \param zoomY if set \c true (default) zooms the y axis
2050 * \param includeX0 if this is \c true zoomToFit() will ensure that \f$ x=0 \f$ is visible in the plot (only for non-logx plots, default: false)
2051 * \param includeY0 if this is \c true zoomToFit() will ensure that \f$ y=0 \f$ is visible in the plot (only for non-logy plots, default: false)
2052 * \param scaleX the plot will have a width of \f$ \mbox{Xscale}\cdot\Delta x \f$ where \f$ \Delta x \f$ is the actual x-axis data range
2053 * For logx plots we actually use this on the logarithmized data! (default: 1.05)
2054 * \param scaleY the plot will have a height of \f$ \mbox{Yscale}\cdot\Delta < \f$ where \f$ \Delta < \f$ is the actual <-axis data range
2055 * For log< plots we actually use this on the logarithmized data! (default: 1.05)
2056 *
2057 */
2058 void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05);
2059
2060 /** \brief zooms into the graph (the same as turning the mouse wheel) by the given factor */
2061 void zoomIn(double factor=2.0);
2062 /** \brief zooms out of the graph (the same as turning the mouse wheel) by the given factor */
2063 void zoomOut(double factor=2.0);
2064
2065 /** \brief en-/disables the maintaining of the data aspect ratio \see aspectRatio */
2066 void setMaintainAspectRatio(bool value);
2067
2068 /** \brief en-/disables the maintaining of the axis aspect ratio \see axisAspectRatio */
2070
2071 /** \brief set filename and prefix, used by loadUserSettings() and saveUserSettings()
2072 *
2073 * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix()
2074 */
2075 void setUserSettigsFilename(const QString& filename, const QString& prefix);
2076 /** \brief set filename, used by loadUserSettings() and saveUserSettings()
2077 *
2078 * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix()
2079 */
2080 void setUserSettigsFilename(const QString& filename);
2081 /** \brief set prefix, used by loadUserSettings() and saveUserSettings()
2082 *
2083 * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix()
2084 */
2085 void setUserSettigsPrefix(const QString& prefix);
2086 /** \brief return the filename, used by loadUserSettings() and saveUserSettings()
2087 *
2088 * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix()
2089 */
2090 QString getUserSettigsFilename() const;
2091 /** \brief return the prefix, used by loadUserSettings() and saveUserSettings()
2092 *
2093 * \see loadUserSettings(), saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix()
2094 */
2095 QString getUserSettigsPrefix() const;
2096
2097 /** \brief loads the plot user properties from the file sepcified by setUserSettigsFilename() and the prefix specified by setUserSettigsPrefix()
2098 *
2099 * \see saveUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix()
2100 */
2102
2103 /** \brief saves the plot user properties to the file sepcified by setUserSettigsFilename() and the prefix specified by setUserSettigsPrefix()
2104 *
2105 * \see loadUserSettings(), setUserSettigsPrefix(), getUserSettigsFilename(), getUserSettigsPrefix()
2106 */
2107 void saveUserSettings() const;
2108
2109 /** \brief set all graphs invisible, except i */
2111
2112 /** \brief set all graphs invisible, except graph start, start+n, start+2*n, ... */
2113 void setOnlyNthGraphsVisible(int start, int n);
2114
2115 /** \brief sets the data aspect ratio, enforced with setMaintainApsectRatio(true) \see aspectRatio */
2116 void setAspectRatio(double __value);
2117 /** \brief sets the axis aspect ratio, enforced with setMaintainAxisApsectRatio(true) \see axisAspectRatio */
2118 void setAxisAspectRatio(double __value);
2119 /** \copydoc JKQTBasePlotterStyle::useAntiAliasingForSystem */
2121 /** \copydoc JKQTGraphsBaseStyle::useAntiAliasingForGraphs */
2123 /** \copydoc JKQTBasePlotterStyle::useAntiAliasingForText */
2124 void setUseAntiAliasingForText(bool __value);
2125 /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
2126 void setBackgroundColor(const QColor & __value);
2127 /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
2128 void setExportBackgroundColor(const QColor & __value);
2129 /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
2130 void setPlotBackgroundColor(const QColor & __value);
2131 /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
2132 void setBackgroundBrush(const QBrush & __value);
2133 /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
2134 void setExportBackgroundBrush(const QBrush & __value);
2135 /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
2136 void setPlotBackgroundBrush(const QBrush & __value);
2137 /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
2138 void setBackgroundGradient(const QGradient & __value);
2139 /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
2140 void setExportBackgroundGradient(const QGradient & __value);
2141 /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
2142 void setPlotBackgroundGradient(const QGradient & __value);
2143 /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
2144 void setBackgroundTexture(const QPixmap & __value);
2145 /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
2146 void setExportBackgroundTexture(const QPixmap & __value);
2147 /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
2148 void setPlotBackgroundTexture(const QPixmap & __value);
2149 /** \copydoc JKQTBasePlotterStyle::widgetBackgroundBrush */
2150 void setBackgroundTexture(const QImage & __value);
2151 /** \copydoc JKQTBasePlotterStyle::exportBackgroundBrush */
2152 void setExportBackgroundTexture(const QImage & __value);
2153 /** \copydoc JKQTBasePlotterStyle::plotBackgroundBrush */
2154 void setPlotBackgroundTexture(const QImage & __value);
2155
2156
2157 /** \copydoc JKQTBasePlotterStyle::plotFrameWidth */
2158 void setPlotFrameWidth(double __value);
2159 /** \copydoc JKQTBasePlotterStyle::plotFrameRounding */
2160 void setPlotFrameRounding(double __value);
2161 /** \copydoc JKQTBasePlotterStyle::plotFrameColor */
2162 void setPlotFrameColor(QColor col);
2163 /** \copydoc JKQTBasePlotterStyle::plotFrameVisible */
2164 void setPlotFrameVisible(bool enabled);
2165
2166
2167 /** \copydoc JKQTPKeyStyle::visible */
2168 void setShowKey(bool __value);
2169 /** \copydoc JKQTPKeyStyle::position */
2170 void setKeyPosition(const JKQTPKeyPosition & __value);
2171 /** \copydoc JKQTBasePlotterStyle::plotLabelFontSize */
2172 void setPlotLabelFontSize(double __value);
2173 /** \copydoc JKQTBasePlotterStyle::plotLabelOffset */
2174 void setPlotLabelOffset(double __value);
2175 /** \copydoc JKQTBasePlotterStyle::plotLabelTopBorder */
2176 void setPlotLabelTopBorder(double __value);
2177 /** \copydoc JKQTBasePlotterStyle::plotLabelFontName */
2178 void setplotLabelFontName(const QString & __value);
2179 /** \copydoc JKQTBasePlotterStyle::plotLabelColor */
2180 void setPlotLabelColor(QColor __value);
2181 /** \brief set the plot label text */
2182 void setPlotLabel(const QString & __value);
2183 /** \copydoc JKQTBasePlotterStyle::defaultTextColor */
2184 void setDefaultTextColor(QColor __value) ;
2185 /** \copydoc JKQTBasePlotterStyle::defaultFontSize */
2186 void setDefaultTextSize(double __value) ;
2187 /** \copydoc JKQTBasePlotterStyle::defaultFontName */
2188 void setDefaultTextFontName(const QString& __value) ;
2189 /** \brief sets the current directory in which to open SaveAs ... dialogs */
2190 void setCurrentSaveDirectory(const QString & __value);
2191 /** \brief set the file format to use in SaveAs ... dialogs */
2192 void setCurrentFileFormat(const QString & __value);
2193 /** \brief set the decimal separator used when exporting data to text files */
2194 void setCSVdecimalSeparator(const QString & __value);
2195 /** \brief set the string used to introduce comments in text output when exporting data */
2196 void setCSVcommentInitializer(const QString & __value);
2197
2198 /** \brief if set \c true (default: \c false ) the JKQTBasePlotter draws colored rectangles to indicate the different regions in the plot (border, axes, ...)
2199 *
2200 * \image html debugShowRegionBoxes.png
2201 *
2202 * \see JKQTBasePlotterStyle::debugShowRegionBoxes, isDebugShowRegionBoxesEnabled()
2203 */
2204 void enableDebugShowRegionBoxes(bool enabled=true);
2205
2206 /** \brief if set \c true (default: \c false ) the JKQTBasePlotter draws colored rectangles to indicate the extent of text in the plot
2207 *
2208 * \image html debugShowTextBoxes.png
2209 *
2210 * \see JKQTBasePlotterStyle::debugShowTextBoxes, isDebugShowRegionTextEnabled()
2211 */
2212 void enableDebugShowTextBoxes(bool enabled=true);
2213 protected:
2214
2215
2216
2217
2218
2219
2220
2221 /** \brief paints the plot onto the given JKQTPEnhancedPainter object
2222 *
2223 * \param painter JKQTPEnhancedPainter to draw on
2224 */
2226 /** \brief simply calls paintPlot() if grid printing mode is deactivated and prints the graph grid otherwise
2227 * \a pageRect is used to determine the size of the page to draw on. If this does not coincide with
2228 * the widget extents this function calculates a scaling factor so the graphs fit onto the page. This
2229 * is especially usefull when printing!
2230 *
2231 * \param painter JKQTPEnhancedPainter to draw on
2232 * \param pageRect size of the page
2233 * \param scaleIfTooLarge scale image if it is too large for pageRect
2234 * \param scaleIfTooSmall scale image if it is smaller than pageRect
2235 */
2236 void gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool scaleIfTooLarge=true, bool scaleIfTooSmall=true);
2237
2238 /** \brief This method goes through all registered plotters and calculates the width of every column and
2239 * height of every row as the max over the row/column. The reults are stored in the private datamembers
2240 * gridPrintingRows and gridPrintingColumns. gridPrintingSize will contain the size of all graphs together
2241 * afterwards. */
2243
2244 /** \brief plot the grid */
2246 /** \brief plot the x coordinate axis (incl. labels) */
2248 /** \brief plot the x coordinate axis (incl. labels) */
2250 /** \brief plot the graphs in the order they appear in the list graphs, i.e. initially the order of the addGraph() calls. So the graph at the end of the list is drawn ON TOP. */
2252 /** \brief plot a key */
2254 /** \brief plot the plot label */
2256
2257 /** \brief show the print preview window for a given print \a p */
2258 bool printpreviewNew(QPaintDevice* paintDevice, bool setAbsolutePaperSize=false, double printsizeX_inMM=-1.0, double printsizeY_inMM=-1.0, bool displayPreview=true);
2259
2260 /** \brief show the export preview window for a given page size \a pageSize, either in pixels (\a unitIsMM \c ==false ) or in millimeters (\a unitIsMM \c ==true ) */
2261 bool exportpreview(QSizeF pageSize, bool unitIsMM=false);
2262
2263 /** \copydoc fontSizeMultiplier */
2264 void setFontSizeMultiplier(double __value);
2265 /** \copydoc lineWidthMultiplier */
2266 void setLineWidthMultiplier(double __value);
2267 /** \copydoc printMagnification */
2268 void setPrintMagnification(double __value);
2269 /** \copydoc printMagnification */
2271 /** \copydoc paintMagnification */
2272 void setPaintMagnification(double __value);
2273 /** \copydoc paintMagnification */
2275
2276
2277 protected Q_SLOTS:
2278 /** \brief internal function for print/export preview
2279 * \internal
2280 */
2282
2283#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
2284 /** \brief internal function for print preview
2285 * \internal
2286 */
2287 void printpreviewPaintRequested(QPrinter *printer);
2288 /** \brief internal function for print preview
2289 * \internal
2290 */
2292#endif
2293 /** \brief internal function for print preview
2294 * \internal
2295 */
2296 void printpreviewPaintRequestedNewPaintDevice(QPaintDevice *paintDevice);
2297 /** \brief internal function for print preview
2298 * \internal
2299 */
2300 void printpreviewSetZoom(double value);
2301 /** \brief internal function for print preview
2302 * \internal
2303 */
2304 void printpreviewSetSizeX(double value);
2305 /** \brief internal function for print preview
2306 * \internal
2307 */
2308 void printpreviewSetSizeY(double value);
2309 /** \brief internal function for print preview
2310 * \internal
2311 */
2312 void printpreviewSetSizeXNew(double value);
2313 /** \brief internal function for print preview
2314 * \internal
2315 */
2316 void printpreviewSetSizeYNew(double value);
2317 /** \brief internal function for print preview
2318 * \internal
2319 */
2321 /** \brief internal function for print preview
2322 * \internal
2323 */
2325 /** \brief internal function for print preview
2326 * \internal
2327 */
2328 void printpreviewSetAspectRatio(bool checked);
2329 /** \brief internal function for print preview
2330 * \internal
2331 */
2333 /** \brief internal function for print preview
2334 * \internal
2335 */
2337 /** \brief internal function for print preview
2338 * \internal
2339 */
2341 /** \brief internal function for print preview
2342 * \internal
2343 */
2345 /** \brief internal function for print preview
2346 * \internal
2347 */
2349
2350 /** \brief internal function for export preview
2351 * \internal
2352 */
2354
2355 /** \brief internal function for getDataColumnsByUser()
2356 * \internal
2357 */
2359 /** \brief internal function for getDataColumnsByUser()
2360 * \internal
2361 */
2363 /** \brief internal function for getDataColumnsByUser()
2364 * \internal
2365 */
2367 /** \brief internal function for getDataColumnsByUser()
2368 * \internal
2369 */
2370 void getDataColumnsByUserComboBoxSelected(const QString& name);
2371 /** \brief internal function for getDataColumnsByUser()
2372 * \internal
2373 */
2374 void getDataColumnsByUserItemChanged(QListWidgetItem* widgetitem);
2375 /** \brief internal function for getDataColumnsByUser()
2376 * \internal
2377 */
2379 /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis */
2380 void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender);
2381 /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local y-axis to the other y-axis */
2382 void synchronizeYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender);
2383 /** \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 */
2384 void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter* sender);
2385
2386 protected:
2387 /** \brief current style properties for this JKQTBasePlotter instance
2388 *
2389 * \see JKQTPSetSystemDefaultBaseStyle(), JKQTPSetSystemDefaultBaseStyle(), getCurrentPlotterStyle(), \ref jkqtpplotter_styling
2390 */
2392
2393 /** \brief copy sub-properties of plotterStyle to sub-objects that require it (axes, axes in graphs ...) and emit a plot update */
2395
2396 /** \brief used to plot LaTeX markup */
2398
2399 /** \brief model representing all Plots in this plotter and showing their visible/invisible state */
2401
2402 /** \brief object used for the x-axis */
2404 /** \brief objects used a secondary x-axes */
2405 QMap<JKQTPCoordinateAxisRef, JKQTPHorizontalAxisBase*> secondaryXAxis;
2406 /** \brief object used for the y-axis */
2408 /** \brief objects used a secondary y-axes */
2409 QMap<JKQTPCoordinateAxisRef, JKQTPVerticalAxisBase*> secondaryYAxis;
2410
2411 /** \brief key objects used for the main plot key */
2413
2414 /** \brief filename for the ini file in which to save the user settings
2415 * \see jkqtplotter_base_userprops
2416 */
2418 /** \brief prefix for the ini file in which to save the user settings
2419 * \see jkqtplotter_base_userprops
2420 */
2422
2423
2424 /** \brief indicates whether the \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" is activated
2425 *
2426 * \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT
2427 */
2429 /** \brief x position of the current graph in \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing"
2430 *
2431 * \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT
2432 */
2434 /** \brief y position of the current graph in \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing"
2435 *
2436 * \see \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT
2437 */
2439 /** \brief list that manages all the additional graphs for \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" mode */
2440 QList<JKQTPGridPrintingItem> gridPrintingList;
2441 /** \brief this list contains all the rows of the current \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" and stores its heights */
2442 QList<size_t> gridPrintingRows;
2443 /** \brief this list contains all the columns of the current \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" and stores its widths */
2444 QList<size_t> gridPrintingColumns;
2445 /** \brief size of all plots in \ref JKQTBASEPLOTTER_SYNCMULTIPLOT_GRIDPRINT "grid printing" mode, filled by gridPrintingCalc() */
2447
2448 /** \brief this is an internal property that is used by the export/print system to control the "magnification". Usually this is 1.0
2449 * but if set !=1.0, it is used to scale the widgetWidth and widgetHeight before painting! */
2451
2452 /** \brief an object which manages all data columns for this plotter class */
2454 /** \brief indicates whether the datastore is managed (allocated/freed) internally or externally */
2456
2457
2458 /** \brief width of the plot widget
2459 *
2460 * \image html plot_widget_orientation.png
2461 *
2462 * \see setWidgetSize(), \ref jkqtplotter_base_plotsize
2463 */
2465
2466 /** \brief height of the plot widget
2467 *
2468 * \image html plot_widget_orientation.png
2469 *
2470 * \see setWidgetSize(), \ref jkqtplotter_base_plotsize
2471 */
2473
2474
2475 /** \brief used for calculated value:describing what freespace outside the graph area is used for
2476 * \internal
2477 */
2479 muOutermost=0,
2480 muUserBorder=0,
2486
2487 // this is always the last one
2489 muInnermost=muUsesCount-1
2491 /** \brief enum to indicate relative position from a central position */
2498
2499 /** \brief used for calculated value: describing a section in the freespace outside the graph area
2500 * \internal
2501 */
2502 struct PlotMargin {
2503 double left;
2504 double right;
2505 double top;
2506 double bottom;
2507
2508 inline PlotMargin(double l=0, double r=0, double t=0, double b=0) : left(l), right(r), top(t), bottom(b) {};
2509
2510 /** \brief select left,right, top, bottom, depending on \a side */
2511 inline double getMargin(PlotMarginSide side) const
2512 {
2513 switch (side) {
2514 case sideLeft:
2515 return left;
2516 case sideRight:
2517 return right;
2518 case sideTop:
2519 return top;
2520 case sideBottom:
2521 return bottom;
2522 }
2523 return 0;
2524 }
2525 };
2526
2527 /** \brief used for calculated value: describing all sections of freespace outside the graph area
2528 * \internal
2529 */
2530 class PlotMargins: public QMap<PlotMarginUse, PlotMargin> {
2531 public:
2532 inline PlotMargins(): QMap<PlotMarginUse, PlotMargin>() {};
2533 /** \brief claculate size of plot margins on the left (sums all) */
2534 double calcLeft() const;
2535 double calcLeft(PlotMarginUse start, PlotMarginUse stop) const;
2536 /** \brief claculate size of plot margins on the right (sums all) */
2537 double calcRight() const;
2538 double calcRight(PlotMarginUse start, PlotMarginUse stop) const;
2539 /** \brief claculate size of plot margins at the top (sums all) */
2540 double calcTop() const;
2541 double calcTop(PlotMarginUse start, PlotMarginUse stop) const;
2542 /** \brief claculate size of plot margins at the bottom (sums all) */
2543 double calcBottom() const;
2544 double calcBottom(PlotMarginUse start, PlotMarginUse stop) const;
2545 };
2546
2547 /** \brief <b>calculated value:</b> description of free space between actual plot and widget borders
2548 * \internal
2549 *
2550 * \image html plot_widget_orientation.png
2551 *
2552 * \note This property is an intermediate storage for calculated values. Do not change directly!
2553 *
2554 * \see calcPlotMarginRect()
2555 */
2557
2558 /** \brief calculate the rectangle to be used for a given PlotMarginUse on the indicated side of the plot
2559 *
2560 * This function evaluates the data in internalPlotMargins also using the other properties known in this class.
2561 * Basically it therefore defines the ordering and interpretation of PlotMarginUse.
2562 *
2563 * \image html plot_widget_orientation.png
2564 *
2565 * \see internalPlotMargins
2566 */
2568 /** \brief calculate the rectangle of the plot (excluding all margins) */
2569 QRectF calcPlotRect() const;
2570
2571
2572
2573 /** \brief <b>calculated value:</b> free space between widget top border and plot top border, as used to plot the graph
2574 * \internal
2575 *
2576 * \image html plot_widget_orientation.png
2577 *
2578 * \note This property is an intermediate storage for calculated values. Do not change directly!
2579 */
2581 /** \brief <b>calculated value:</b> height of the plot title (or 0 if no title)
2582 * \internal
2583 *
2584 * \image html plot_widget_orientation.png
2585 *
2586 * \note This property is an intermediate storage for calculated values. Do not change directly!
2587 */
2589
2590 /** \brief <b>calculated value:</b> free space between widget top border and plot top border, as used to plot the graph
2591 * \internal
2592 *
2593 * \image html plot_widget_orientation.png
2594 *
2595 * \note This property is an intermediate storage for calculated values. Do not change directly!
2596 */
2598
2599 /** \brief <b>calculated value:</b> free space between widget top border and plot top border, as used to plot the graph
2600 * \internal
2601 *
2602 * \image html plot_widget_orientation.png
2603 *
2604 * \note This property is an intermediate storage for calculated values. Do not change directly!
2605 */
2607
2608 /** \brief <b>calculated value:</b> free space between widget top border and plot top border, as used to plot the graph
2609 * \internal
2610 *
2611 * \image html plot_widget_orientation.png
2612 *
2613 * \note This property is an intermediate storage for calculated values. Do not change directly!
2614 */
2616
2617 /** \brief <b>calculated value:</b> size and location of the plot key
2618 * \internal
2619 *
2620 * \image html plot_widget_orientation.png
2621 *
2622 * \note This property is an intermediate storage for calculated values. Do not change directly!
2623 */
2625
2626
2627
2628
2629
2630 /** \brief <b>calculated value:</b> plot width in pixel inside the widget (calculated by calcPlotScaling() from plotBorderLeft, plotBorderRight and widgetWidth)
2631 *
2632 * \image html plot_widget_orientation.png
2633 *
2634 * \see \ref jkqtplotter_base_plotsize
2635 */
2637 /** \brief <b>calculated value:</b> plot height in pixel inside the widget (calculated by calcPlotScaling() from plotBorderTop, plotBorderBottom and widgetHeight)
2638 *
2639 * \image html plot_widget_orientation.png
2640 *
2641 * \see \ref jkqtplotter_base_plotsize
2642 */
2644
2645 /** \brief indicates whether the widget should maintain an aspect ratio of plotwidth and plotheight
2646 *
2647 * \see aspectRatio
2648 */
2650 /** \brief the aspect ratio of plotwidth and plotheight to maintain, if \c maintainAspectRatio==true
2651 *
2652 * \f[ \mbox{aspectRatio}=\frac{\mbox{plotWidth}}{\mbox{plotHeight}} \f]
2653 *
2654 * \see maintainAspectRatio
2655 */
2657
2658 /** \brief indicates whether the axes should maintain an aspect ratio
2659 *
2660 * When the axis aspect ratio is to be maintained and new axis ranges are set (e.g. when calling setXY() ),
2661 * the given axis ranges are modified, so
2662 * \f[ \mbox{axisAspectRatio}=\frac{\left|x_\text{max}-x_\text{min}\right|}{\left|y_\text{max}-y_\text{min}\right|} \f]
2663 *
2664 * \note An axis aspect ratio is only well defined for linear axes (if both axes are linear).
2665 * If both axes a logarithmic, the axis ration is defined for log(axismax)-log(axismin).
2666 * For other combinations of axes, this function is deactivated
2667 *
2668 * \see axisAspectRatio
2669 */
2671 /** \brief the aspect ratio of axis widths to maintain, if \c maintainAxisAspectRatio==true
2672 *
2673 * When the axis aspect ratio is to be maintained and new axis ranges are set (e.g. when calling setXY() ),
2674 * the given axis ranges are modified, so
2675 * \f[ \mbox{axisAspectRatio}=\frac{\left|x_\text{max}-x_\text{min}\right|}{\left|y_\text{max}-y_\text{min}\right|} \f]
2676 *
2677 * \note An axis aspect ratio is only well defined for linear axes (if both axes are linear).
2678 * If both axes a logarithmic, the axis ration is defined for log(axismax)-log(axismin).
2679 * For other combinations of axes, this function is deactivated
2680 *
2681 * \see maintainAxisAspectRatio
2682 */
2684
2685
2686 /** \brief the plot label text */
2687 QString plotLabel;
2688
2689
2690 /** \brief calculate the scaling and offset values from axis min/max values */
2692
2693 /** \brief set the standard settings (colors, line widths ...) */
2695
2696
2697 /** \brief specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate() */
2699
2700 /** \brief multiplier which is used for font sizes when the plot is exported/printed */
2702
2703 /** \brief multiplier which is used for linewidths when the plot is exported/printed */
2705
2706 /** \brief multiplier for the font size */
2708 /** \brief multiplier or the line widths */
2710
2711 /** \brief internal: used to store a list of all currently used plot styles */
2712 QList<int> usedStyles;
2713
2714
2715 /** \brief a vector that contains all graphs to be plottet in the system */
2717
2718
2719
2720
2721 /** \brief indicates whether to use clipping (hack for printing, see print() ) */
2723
2724
2725
2726
2727 /** \brief QAction which triggers saving of the plot as an image */
2728 QAction* actSavePlot;
2729 /** \brief QAction which triggers saving of the data used for the plot */
2730 QAction* actSaveData;
2731 /** \brief QAction which triggers copying of the data to the clipboard */
2732 QAction* actCopyData;
2733 /** \brief QAction which triggers copying of the image to the clipboard */
2735 /** \brief QAction which triggers copying of the data to the clipboard in Matlab format */
2737#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
2738 /** \brief QAction which triggers the saving as PDF */
2739 QAction* actSavePDF;
2740 /** \brief QAction which triggers the saving as Scalable Vector Graphics (SVG) */
2741 QAction* actSaveSVG;
2742 /** \brief QAction which triggers the printing */
2743 QAction* actPrint;
2744#endif
2745 /** \brief QAction which triggers the saving as pixel image */
2746 QAction* actSavePix;
2747 /** \brief QAction which triggers the saving as CSV (data only) */
2748 QAction* actSaveCSV;
2749 /** \brief QAction which triggers zoom all */
2750 QAction* actZoomAll;
2751 /** \brief QAction which triggers zoom in */
2752 QAction* actZoomIn;
2753 /** \brief QAction which triggers zoom out */
2754 QAction* actZoomOut;
2755 /** \brief QAction to show a table with all the plot data in the datastore */
2757 /** \brief this list contains additional actions, that can be registered by registerAdditionalAction(). They are shown in the context menu only and are e.g. used to display "save image data" actions. Each action may be in a category (key of map), which is displayed as a submenu of the context-menu! */
2759 /** \brief the current directory in which to open SaveAs ... dialogs */
2761 /** \brief the current file format to use in SaveAs ... dialogs */
2763 /** \brief the current file format to use in SaveDataAs ... dialogs */
2765 /** \brief the currently selected printer */
2767
2768 /** \brief the master plotter for x-dimension, this plotter is connected to. */
2770 /** \brief the master plotter for y-dimension, this plotter is connected to. */
2772 /** \brief synchronize plot width with masterPlotterX */
2774 /** \brief synchronize plot height with masterPlotterY */
2776
2777
2778 /** \brief controls, whether the signals plotUpdated() are emitted */
2780
2781
2784 static std::mutex globalUserSettingsMutex;
2787
2788
2789
2793 QMap<QString, QStringList> getDataColumnsByUserSaved;
2794
2795
2796 private:
2801#ifndef JKQTPLOTTER_COMPILE_WITHOUT_PRINTSUPPORT
2802 QPointer<QPrintPreviewWidget> printPreview;
2803#endif
2804 QPointer<JKQTPEnhancedDoubleSpinBox> spinSizeX;
2805 QPointer<JKQTPEnhancedDoubleSpinBox> spinSizeY;
2806 QPointer<QLabel> exportPreviewLabel;
2807 QPointer<JKQTPEnhancedDoubleSpinBox> spinMagnification;
2817
2818
2819
2820
2821
2822};
2823
2824/** \brief qHash()-specialization
2825 * \ingroup jkqtpplottersupprt
2826 */
2827#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
2828inline size_t qHash(const JKQTBasePlotter::textSizeKey& data, size_t /*seed=0*/) {
2829#else
2830inline uint qHash(const JKQTBasePlotter::textSizeKey& data, uint /*seed=0*/) {
2831#endif
2832 std::size_t seed=0;
2833 jkqtp_hash_combine(seed, data.f);
2834 jkqtp_hash_combine(seed, data.text);
2835 return seed;
2836}
2837
2838#endif // JKQTPBASEPLOTTER_H
represents a pen, when plotting in JKQTPlotter/JKQTBasePlotter
Definition jkqtpbaseplotter.h:764
void setSymbolFillColor(QColor c)
void setFillColor(const QColor &col)
Qt::BrushStyle m_errorFillStyle
Definition jkqtpbaseplotter.h:777
double m_symbolSize
Definition jkqtpbaseplotter.h:775
void setColor(const QColor &col)
QColor errorFillColor() const
Qt::PenStyle errorStyle() const
QColor fillColor() const
void setSymbolType(JKQTPGraphSymbols symbol)
void setFillStyle(const JKQTFillStyleSummmary &s)
QColor m_errorColor
Definition jkqtpbaseplotter.h:769
void setStyle(Qt::PenStyle s)
QColor errorColor() const
void setErrorLineWidth(double w)
void setSymbolSize(double w)
double m_width
Definition jkqtpbaseplotter.h:771
QColor m_color
Definition jkqtpbaseplotter.h:766
QColor m_symbolFillColor
Definition jkqtpbaseplotter.h:768
double symbolLineWidthF() const
JKQTFillStyleSummmary m_fillStyle
Definition jkqtpbaseplotter.h:776
void setErrorFillColor(const QColor &col)
void setErrorFillStyle(Qt::BrushStyle s)
Qt::PenStyle m_style
Definition jkqtpbaseplotter.h:774
JKQTFillStyleSummmary fillStyle() const
QColor symbolFillColor() const
JKQTPGraphSymbols symbol() const
void setSymbolLineWidthF(double w)
QColor m_fillColor
Definition jkqtpbaseplotter.h:767
double m_errorWidth
Definition jkqtpbaseplotter.h:772
double symbolSize() const
void setErrorLineColor(const QColor &col)
double m_symbolLineWidth
Definition jkqtpbaseplotter.h:773
void setWidthF(double w)
Qt::PenStyle style() const
Qt::BrushStyle errorFillStyle() const
double errorWidthF() const
QColor m_errorFillColor
Definition jkqtpbaseplotter.h:770
JKQTPGraphSymbols m_symbol
Definition jkqtpbaseplotter.h:778
used for calculated value: describing all sections of freespace outside the graph area
Definition jkqtpbaseplotter.h:2530
double calcLeft() const
claculate size of plot margins on the left (sums all)
double calcTop() const
claculate size of plot margins at the top (sums all)
PlotMargins()
Definition jkqtpbaseplotter.h:2532
double calcTop(PlotMarginUse start, PlotMarginUse stop) const
double calcRight() const
claculate size of plot margins on the right (sums all)
double calcBottom() const
claculate size of plot margins at the bottom (sums all)
double calcBottom(PlotMarginUse start, PlotMarginUse stop) const
double calcRight(PlotMarginUse start, PlotMarginUse stop) const
double calcLeft(PlotMarginUse start, PlotMarginUse stop) const
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
void initSettings()
set the standard settings (colors, line widths ...)
void printpreviewSetMagnificationNew(double value)
internal function for print preview
double pt2px(double pt, JKQTPEnhancedPainter &painter) const
returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch)
Definition jkqtpbaseplotter.h:846
void setDefaultTextSize(double __value)
default font size in the plot [pt]
int widgetWidth
width of the plot widget
Definition jkqtpbaseplotter.h:2464
JKQTBasePlotterStyle plotterStyle
current style properties for this JKQTBasePlotter instance
Definition jkqtpbaseplotter.h:2391
void setMinorGridWidth(double __value)
sets the width of all minor grid lines
void setPlotLabelOffset(double __value)
offset of the plot label from the next element of the graph, i.e. below the label [pt].
void beforePlotScalingRecalculate()
emitted before the plot scaling has been recalculated
void moveGraphBottom(const JKQTPPlotElement *gr)
move the given graph gr to the bottom of all graphs
double internalPlotBorderLeft
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:2597
QRectF calcPlotMarginRect(PlotMarginUse use, PlotMarginSide side) const
calculate the rectangle to be used for a given PlotMarginUse on the indicated side of the plot
void setAspectRatio(double __value)
sets the data aspect ratio, enforced with setMaintainApsectRatio(true)
void useAsInternalDatastore(JKQTPDatastore *newStore)
tells the plotter object to use the given external datastore and treat it as an internal one (i....
double getLineWidthPrintMultiplier() const
multiplier which is used for linewidths when the plot is exported/printed
void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx)
sets absolutely limiting x- and y-range of the plot
void setCurrentFileFormat(const QString &__value)
set the file format to use in SaveAs ... dialogs
double getPlotLabelFontSize() const
the plot label font size [pt]
void setPrintMagnification(double __value)
void showPlotData()
internal function for getDataColumnsByUser()
QMap< JKQTPCoordinateAxisRef, JKQTPHorizontalAxisBase * > secondaryXAxis
objects used a secondary x-axes
Definition jkqtpbaseplotter.h:2405
void setPlotBackgroundGradient(const QGradient &__value)
color of the plot's background (i.e. of the area within the coordinate axes rectangle)
QAction * getActionSaveSVG() const
QAction which triggers the saving as Scalable Vector Graphics (SVG)
QString getUserSettigsFilename() const
return the filename, used by loadUserSettings() and saveUserSettings()
void zoomIn(double factor=2.0)
zooms into the graph (the same as turning the mouse wheel) by the given factor
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.
QAction * getActionSaveCSV() const
QAction which triggers the saving as CSV (data only)
bool isUsingAntiAliasingForSystem() const
specifies whether to use antialiasing for plotting the coordinate system
JKQTMathTextNodeSize getTextSizeDetail(const QFont &fm, const QString &text, QPainter &painter)
calculates a JKQTMathTextNodeSize for the given string text if it would be drawn on painter with font...
double getXMax() const
returns the current x-axis max of the primary x-axis
double fontSizePrintMultiplier
multiplier which is used for font sizes when the plot is exported/printed
Definition jkqtpbaseplotter.h:2701
QAction * actShowPlotData
QAction to show a table with all the plot data in the datastore.
Definition jkqtpbaseplotter.h:2756
double didot2px(double pt, JKQTPEnhancedPainter &painter) const
returns the given size in Didot points (0.376 mm) to pixels (with dpi from painter)
Definition jkqtpbaseplotter.h:833
int indexOfGraph(const JKQTPPlotElement *gr) const
returns the index of the given graph gr in the graphs list, or -1 if it was not found
void setDefaultTextColor(QColor __value)
default text color in the plot
double getYMin() const
returns the current y-axis min of the primary y-axis
void setMaintainAspectRatio(bool value)
en-/disables the maintaining of the data aspect ratio
bool maintainAxisAspectRatio
indicates whether the axes should maintain an aspect ratio
Definition jkqtpbaseplotter.h:2670
double getAbsoluteYMax() const
returns the absolute y-axis max of the primary y-axis This is the highest allowed value the the axis ...
void printpreviewPaintRequestedNewPaintDevice(QPaintDevice *paintDevice)
internal function for print preview
void setGridColor(QColor color)
sets the color of all major grid lines (of the major x- and y-axis)
double pt2px(double pt, double dpi) const
returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch)
Definition jkqtpbaseplotter.h:842
const JKQTPHorizontalAxisBase * getXAxis(JKQTPCoordinateAxisRef axis=JKQTPPrimaryAxis) const
returns the x-axis objet of the plot
virtual ~JKQTBasePlotter()
class destructor
bool printScaleToPagesize
Definition jkqtpbaseplotter.h:2811
QPointer< JKQTPEnhancedDoubleSpinBox > spinSizeY
Definition jkqtpbaseplotter.h:2805
QAction * getActionCopyData() const
QAction which triggers copying of the data to the clipboard.
QSizeF gridPrintingSize
size of all plots in grid printing mode, filled by gridPrintingCalc()
Definition jkqtpbaseplotter.h:2446
void setUserSettigsPrefix(const QString &prefix)
set prefix, used by loadUserSettings() and saveUserSettings()
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...
double getPlotLabelTopBorder() const
offset of the plot label from the top [pt].
void setLineWidthPrintMultiplier(double __value)
multiplier which is used for linewidths when the plot is exported/printed
void registerAdditionalAction(const QString &key, QAction *act)
this function registers additional actions to lstAdditionalPlotterActions, which are displayed in the...
void setUseAntiAliasingForSystem(bool __value)
specifies whether to use antialiasing for plotting the coordinate system
QString getUserSettigsPrefix() const
return the prefix, used by loadUserSettings() and saveUserSettings()
bool isUsingAntiAliasingForText() const
specifies whether to use antialiasing when drawing any text
void setPlotFrameVisible(bool enabled)
if true, JKQTBasePlotter will draw a rectangle/frame around the plot
bool isUsingAntiAliasingForGraphs() const
specifies whether to use antialiasing for plotting the graphs
bool doesMaintainAspectRatio() const
returns whether the maintaining of the data aspect ratio is enabled or disabled
void saveCurrentPlotterStyle(QSettings &settings, const QString &group="plots/") const
store the current style properties for this JKQTBasePlotter with properties loaded from settings
int getPlotWidth() const
calculated value: plot width in pixel inside the widget (calculated by calcPlotScaling() from plotBor...
Definition jkqtpbaseplotter.h:1153
QVector< JKQTPPlotElement * > GraphsList
Definition jkqtpbaseplotter.h:487
double pt2px(JKQTPEnhancedPainter &painter, double pt) const
returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch)
Definition jkqtpbaseplotter.h:850
void calcPlotScaling(JKQTPEnhancedPainter &painter)
calculate the scaling and offset values from axis min/max values
QAction * getActionSavePlot() const
QAction which triggers saving of the plot as an image.
JKQTPDatastore * datastore
an object which manages all data columns for this plotter class
Definition jkqtpbaseplotter.h:2453
void loadUserSettings(const QSettings &settings, const QString &group=QString("plots_user/"))
loads the plot user properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings obje...
QString getPlotLabel() const
the plot label text
void drawSystemYAxis(JKQTPEnhancedPainter &painter)
plot the x coordinate axis (incl. labels)
PlotMargins internalPlotMargins
calculated value: description of free space between actual plot and widget borders
Definition jkqtpbaseplotter.h:2556
JKQTPHorizontalAxisBase * getXAxis(JKQTPCoordinateAxisRef axis=JKQTPPrimaryAxis)
returns the x-axis objet of the plot
void useExternalDatastore(JKQTPDatastore *newStore)
tells the plotter object to use the given external datastore.
size_t addGraph(JKQTPPlotElement *gr)
Definition jkqtpbaseplotter.h:566
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
void printpreviewPaintRequested(QPrinter *printer)
internal function for print preview
QSizeF getTextSizeSize(const QString &fontName, double fontSize, const QString &text, QPainter &painter)
calculates a size of the given string text if it would be drawn on painter with font fontName and fon...
void saveAsCSV(const QString &filename, const QString &decimalSeparator, const QString &commentInitializer)
save the current plot data as a Comma Separated Values (CSV) file
void setShowKey(bool __value)
indicates whether to plot a key
size_t gridPrintingCurrentY
y position of the current graph in grid printing
Definition jkqtpbaseplotter.h:2438
void setPlotBorderTop(int top)
sets the top border of the plot
void printpreviewSetSizeYNew(double value)
internal function for print preview
QList< size_t > gridPrintingRows
this list contains all the rows of the current grid printing and stores its heights
Definition jkqtpbaseplotter.h:2442
bool exportpreview(QSizeF pageSize, bool unitIsMM=false)
show the export preview window for a given page size pageSize, either in pixels (unitIsMM ==false ) o...
QAction * actZoomOut
QAction which triggers zoom out.
Definition jkqtpbaseplotter.h:2754
void setGridPrintingCurrentX(size_t __value)
x position of the current graph in grid printing
bool 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,...
void gridPrintingCalc()
This method goes through all registered plotters and calculates the width of every column and height ...
void drawSystemXAxis(JKQTPEnhancedPainter &painter)
plot the x coordinate axis (incl. labels)
double getInternalPlotBorderRight() const
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:1151
const JKQTPVerticalAxisBase * getYAxis(JKQTPCoordinateAxisRef axis=JKQTPPrimaryAxis) const
returns the y-axis objet of the plot
void setShowZeroAxes(bool showX, bool showY)
switches the visibility of the zero-axes associated with the major x- and y-axis
int getPlotBorderLeft() const
free space between widget left border and plot left border, this property may be set by the user and ...
void setPlotFrameRounding(double __value)
if plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot,...
void setOnlyNthGraphsVisible(int start, int n)
set all graphs invisible, except graph start, start+n, start+2*n, ...
void useInternalDatastore()
tells the plotter object to use an internal datastore. A new internal datastore object is generated o...
void setPlotFrameColor(QColor col)
if plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this color
size_t getGridPrintingCurrentY() const
y position of the current graph in grid printing
void setExportBackgroundGradient(const QGradient &__value)
color of the background of the plot (widget area) when exporting
int internalPlotWidth
calculated value: plot width in pixel inside the widget (calculated by calcPlotScaling() from plotBor...
Definition jkqtpbaseplotter.h:2636
QString currentFileFormat
the current file format to use in SaveAs ... dialogs
Definition jkqtpbaseplotter.h:2762
void saveAsGerExcelCSV(const QString &filename=QString(""))
save the current plot data as a Semicolon Separated Values (CSV) file for german Excel,...
QBrush getBackgroundBrush() const
color of the background of the plot (widget area) when drawing (to the screen)
void setPlotLabelFontSize(double __value)
the plot label font size [pt]
QMapIterator< QString, QList< QPointer< QAction > > > AdditionalActionsMapIterator
Definition jkqtpbaseplotter.h:398
void printpreviewSetSizeX(double value)
internal function for print preview
static void registerPaintDeviceAdapter(JKQTPPaintDeviceAdapter *adapter)
register a user-defined QPaintDevice (with factory JKQTPPaintDeviceAdapter) as a plugin to JKQTBasePl...
double internalPlotBorderRight
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:2615
void zoom(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 jkqtpbaseplotter.h:1933
void updatePreviewLabel()
internal function for print/export preview
QAction * actSavePlot
QAction which triggers saving of the plot as an image.
Definition jkqtpbaseplotter.h:2728
QAction * getActionCopyPixelImage() const
QAction which triggers copying of the image to the clipboard.
void beforePrinting()
emitted just before Printing the current plot as image, or just before the print preview dialog is sh...
void setMaintainAxisAspectRatio(bool value)
en-/disables the maintaining of the axis aspect ratio
void beforeExporting()
emitted just before exporting the current plot as image, or just before the export preview dialog is ...
void drawPlot(JKQTPEnhancedPainter &painter)
paints the plot onto the given JKQTPEnhancedPainter object
void getTextSizeDetail(const QFont &fm, const QString &text, QPainter &painter, double &width, double &ascent, double &descent, double &strikeoutPos)
calculates a text-size details for the given string text if it would be drawn on painter with font fm
QAction * actSavePDF
QAction which triggers the saving as PDF.
Definition jkqtpbaseplotter.h:2739
double getAxisAspectRatio() const
returns the axis aspect ratio, enforced with setMaintainAxisApsectRatio(true)
QColor getPlotLabelColor() const
the plot label color
void setAllGraphsVisible()
set all graphs in the plotter visible
const JKQTMathText * getMathText() const
returns the internal JKQTMathText, used to render text with LaTeX markup
QList< const JKQTPCoordinateAxis * > getAxes(bool includePrimaries=true) const
returns all available x- or y-axes
void setExportBackgroundTexture(const QPixmap &__value)
color of the background of the plot (widget area) when exporting
double axisAspectRatio
the aspect ratio of axis widths to maintain, if maintainAxisAspectRatio==true
Definition jkqtpbaseplotter.h:2683
void setBackgroundTexture(const QImage &__value)
color of the background of the plot (widget area) when drawing (to the screen)
void setPlotLabelTopBorder(double __value)
offset of the plot label from the top [pt].
void setUseAntiAliasingForGraphs(bool __value)
specifies whether to use antialiasing for plotting the graphs
JKQTBasePlotter * masterPlotterY
the master plotter for y-dimension, this plotter is connected to.
Definition jkqtpbaseplotter.h:2771
QPointer< JKQTPEnhancedDoubleSpinBox > spinMagnification
Definition jkqtpbaseplotter.h:2807
void copyDataMatlab()
copy the data used for the current plot to the clipboard as a Matlab script
void getDataColumnsByUserComboBoxSelected(const QString &name)
internal function for getDataColumnsByUser()
void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter *sender)
may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the...
bool masterSynchronizeHeight
synchronize plot height with masterPlotterY
Definition jkqtpbaseplotter.h:2775
GraphsConstIterator cbeginGraphs() const
returns a const iterator to the first graph
Definition jkqtpbaseplotter.h:538
void setPlotBorderBottom(int bottom)
sets the bottom border of the plot
void synchronizeXToMaster(JKQTBasePlotter *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 aspectRatio
the aspect ratio of plotwidth and plotheight to maintain, if maintainAspectRatio==true
Definition jkqtpbaseplotter.h:2656
double didot2px(JKQTPEnhancedPainter &painter, double pt) const
returns the given size in Didot points (0.376 mm) to pixels (with dpi from painter)
Definition jkqtpbaseplotter.h:837
QColor getPlotFrameColor() const
if plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this color
void clearGraphs(bool deleteGraphs=true)
remove all plots
QBrush getExportBackgroundBrush() const
color of the background of the plot (widget area) when exporting
void printpreviewSetFontSizeMultiplier(double value)
internal function for print preview
QString getCSVdecimalSeparator() const
returns the decimal separator used when exporting data to text files
void setKeyPosition(const JKQTPKeyPosition &__value)
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples
double paintMagnification
this is an internal property that is used by the export/print system to control the "magnification"....
Definition jkqtpbaseplotter.h:2450
QList< int > usedStyles
internal: used to store a list of all currently used plot styles
Definition jkqtpbaseplotter.h:2712
JKQTPKeyStyle & getMainKeyStyle()
retuns the JKQTPKeyStyle to be used for the main key (extracted from JKQTBasePlotterStyle::keyStyle)
bool isEmittingSignalsEnabled() const
returns whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate()
int widgetHeight
height of the plot widget
Definition jkqtpbaseplotter.h:2472
void setPlotBackgroundColor(const QColor &__value)
color of the plot's background (i.e. of the area within the coordinate axes rectangle)
void setMinorGridColor(QColor color)
sets the color of all minor grid lines (of the major x- and y-axis)
void setPlotLabel(const QString &__value)
set the plot label text
QString currentDataFileFormat
the current file format to use in SaveDataAs ... dialogs
Definition jkqtpbaseplotter.h:2764
void propagateStyle()
copy sub-properties of plotterStyle to sub-objects that require it (axes, axes in graphs ....
JKQTBasePlotter * masterPlotterX
the master plotter for x-dimension, this plotter is connected to.
Definition jkqtpbaseplotter.h:2769
void gridPaint(JKQTPEnhancedPainter &painter, QSizeF pageRect, bool scaleIfTooLarge=true, bool scaleIfTooSmall=true)
simply calls paintPlot() if grid printing mode is deactivated and prints the graph grid otherwise pag...
const JKQTPPlotElement * getGraph(size_t i) const
returns description of i'th graph
bool useClipping
indicates whether to use clipping (hack for printing, see print() )
Definition jkqtpbaseplotter.h:2722
void saveAsDIF(const QString &filename=QString(""))
save the current plot data as a Data Interchange Format file (see https://en.wikipedia....
void printpreviewSetZoom(double value)
internal function for print preview
double x2p(double x) const
return x-pixel coordinate from x coordinate, using the primary axis
Definition jkqtpbaseplotter.h:868
QAction * actZoomIn
QAction which triggers zoom in.
Definition jkqtpbaseplotter.h:2752
JKQTMathText * getMathText()
returns the internal JKQTMathText, used to render text with LaTeX markup
double getAspectRatio() const
returns the data aspect ratio, enforced with setMaintainApsectRatio(true)
JKQTPPlotElement * getGraph(size_t i)
returns description of i'th graph
SynchronizationDirection
denotes, which axes to synchronize in synchronizeToMaster()
Definition jkqtpbaseplotter.h:1348
@ sdXAxis
x-axis only
Definition jkqtpbaseplotter.h:1349
@ sdYAxis
y-axis only
Definition jkqtpbaseplotter.h:1350
QRectF calcPlotRect() const
calculate the rectangle of the plot (excluding all margins)
QAction * actSavePix
QAction which triggers the saving as pixel image.
Definition jkqtpbaseplotter.h:2746
bool isPlotFrameVisible() const
if true, JKQTBasePlotter will draw a rectangle/frame around the plot
void plotScalingRecalculated()
emitted when the plot scaling had to be recalculated
QMap< JKQTPCoordinateAxisRef, JKQTPVerticalAxisBase * > getYAxes(bool includePrimary=true)
returns all available y-axes
void enableDebugShowTextBoxes(bool enabled=true)
if set true (default: false ) the JKQTBasePlotter draws colored rectangles to indicate the extent of ...
GraphsList & getGraphs()
returns a list of all graphs
Definition jkqtpbaseplotter.h:525
QAction * getActionZoomIn() const
QAction which triggers zoom in.
double getPlotLabelOffset() const
offset of the plot label from the next element of the graph, i.e. below the label [pt].
void setPlotFrameWidth(double __value)
if plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this width ...
void moveGraphTop(const JKQTPPlotElement *gr)
move the given graph gr to the end of all graphs, so it is drawn
int getPlotBorderRight() const
free space between widget right border and plot right border, this property may be set by the user an...
void deleteGraph(JKQTPPlotElement *gr, bool deletegraph=true)
remove the given graph, if it is contained
static std::mutex globalUserSettingsMutex
Definition jkqtpbaseplotter.h:2784
bool printKeepAspect
Definition jkqtpbaseplotter.h:2813
int getPlotBorderTop() const
free space between widget top border and plot top border, this property may be set by the user and is...
void setGrid(bool val)
sets whether the major grid lines of the major axes are shown
void setAbsoluteX(double xminn, double xmaxx)
sets absolutely limiting x-range of the plot
bool printKeepAbsoluteFontSizes
Definition jkqtpbaseplotter.h:2810
JKQTMathText mathText
used to plot LaTeX markup
Definition jkqtpbaseplotter.h:2397
bool printDoUpdate
Definition jkqtpbaseplotter.h:2816
void correctXYRangeForAspectRatio(double &xminn, double &xmaxx, double &yminn, double &ymaxx) const
takes a new axis range xminn ... xmaxx and yminn ... ymaxx and corrects the values to match the curre...
QColor getDefaultTextColor() const
default text color in the plot
double getPlotFrameWidth() const
if plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot in this width ...
void setDefaultTextFontName(const QString &__value)
default font name in the plot
QAction * actCopyMatlab
QAction which triggers copying of the data to the clipboard in Matlab format.
Definition jkqtpbaseplotter.h:2736
void setPlotBackgroundTexture(const QImage &__value)
color of the plot's background (i.e. of the area within the coordinate axes rectangle)
void setUserSettigsFilename(const QString &filename, const QString &prefix)
set filename and prefix, used by loadUserSettings() and saveUserSettings()
double getYMax() const
returns the current y-axis max of the primary y-axis
void printpreviewSetSizeY(double value)
internal function for print preview
bool isDebugShowTextBoxesEnabled() const
if set true (default: false ) the JKQTBasePlotter draws colored rectangles to indicate the extent of ...
void drawPlotLabel(JKQTPEnhancedPainter &painter)
plot the plot label
void loadCurrentPlotterStyle(const QSettings &settings, const QString &group="plots/")
replace the current style properties for this JKQTBasePlotter with properties loaded from settings
void loadSettings(const QSettings &settings, const QString &group=QString("plots/"))
loads all the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings objec...
void print(QPrinter *printer=nullptr, bool displayPreview=true)
print the current plot, if printer is nullptr a printer selection dialog is displayed
QSet< JKQTPCoordinateAxisRef > getAvailableXAxisRefs(bool includePrimary=false) const
returns the set of available x-axes (including the primary, if true is given as parameter)
bool emitSignals
specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate...
Definition jkqtpbaseplotter.h:2698
const GraphsList & getGraphs() const
returns a const list of all graphs
Definition jkqtpbaseplotter.h:517
double printSizeY_Millimeter
Definition jkqtpbaseplotter.h:2799
QImage grabPixelImage(QSize size=QSize(), bool showPreview=false)
returns a rendering of the current plot as a QImage (pixel image) with the given size
std::function< bool(const JKQTPPlotElement *)> PlotElementPreciate
Functor which can be used as filter predicate for getGraphsXMinMax() or getGraphsYMinMax()
Definition jkqtpbaseplotter.h:649
void forceInternalDatastore()
tells the plotter object to use an internal datastore (just like useInternalDatastore() ),...
void saveUserSettings(QSettings &settings, const QString &group=QString("plots_user/")) const
saves the plot user properties into a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings obje...
QString getCurrentSaveDirectory() const
returns the current directory in which to open SaveAs ... dialogs
void printpreviewToggleMagnification(bool checked)
internal function for print preview
void setShowZeroAxes(bool showXY)
switches the visibility of the zero-axes associated with the major x- and y-axis
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....
bool masterSynchronizeWidth
synchronize plot width with masterPlotterX
Definition jkqtpbaseplotter.h:2773
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 ...
void setPlotBorder(int left, int right, int top, int bottom)
sets the borders of the plot
JKQTPDatastore * getDatastore()
returns a pointer to the datastore used by this object
Definition jkqtpbaseplotter.h:449
QList< JKQTPCoordinateAxis * > getAxes(bool includePrimaries=true)
returns all available x- or y-axes
double y2p(double y) const
return y-pixel coordinate from y coordinate, using the primary axis
Definition jkqtpbaseplotter.h:873
double printSizeX_Millimeter
Definition jkqtpbaseplotter.h:2798
void setGridPrintingCurrentY(size_t __value)
y position of the current graph in grid printing
double internalPlotBorderBottom
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:2606
void getDataColumnsByUserCheckAll()
internal function for getDataColumnsByUser()
JKQTPBaseKey * mainKey
key objects used for the main plot key
Definition jkqtpbaseplotter.h:2412
QPointer< QLabel > exportPreviewLabel
Definition jkqtpbaseplotter.h:2806
int internalPlotHeight
calculated value: plot height in pixel inside the widget (calculated by calcPlotScaling() from plotBo...
Definition jkqtpbaseplotter.h:2643
void synchronizeYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter *sender)
may be connected to zoomChangedLocally() of a different plot and synchronizes the local y-axis to the...
JKQTPGraphsModel * m_plotsModel
model representing all Plots in this plotter and showing their visible/invisible state
Definition jkqtpbaseplotter.h:2400
QList< JKQTPGridPrintingItem > gridPrintingList
list that manages all the additional graphs for grid printing mode
Definition jkqtpbaseplotter.h:2440
QString currentSaveDirectory
the current directory in which to open SaveAs ... dialogs
Definition jkqtpbaseplotter.h:2760
bool getGraphsYMinMax(double &miny, double &maxy, double &smallestGreaterZero, const PlotElementPreciate &predicate=allPlotElements())
get the maximum and minimum y-value over all graphs in the plot
QSet< JKQTPCoordinateAxisRef > getAvailableYAxisRefs(bool includePrimary=false) const
returns the set of available y-axes (including the primary, if true is given as parameter)
void setWidgetWidth(int wid)
sets the width of the plot widget
QBrush getPlotBackgroundBrush() const
color of the plot's background (i.e. of the area within the coordinate axes rectangle)
static bool registerSaveDataAdapter(JKQTPSaveDataAdapter *adapter)
register a JKQTPSaveDataAdapter with JKQTPlotter/JKQTBasePlotter that can be used to export data from...
double mm2px(double mm, double dpi) const
returns the given size in millimeters to pixels (with given dots per inch)
Definition jkqtpbaseplotter.h:855
int getWidth()
gets the width of the plot widget
void setWidgetSize(QSize size)
resize the plot
void saveAsMatlab(const QString &filename=QString(""))
save the current plot data as a Matlab Script
JKQTPVerticalAxis * yAxis
object used for the y-axis
Definition jkqtpbaseplotter.h:2407
void setWidgetSize(int width, int height)
resize the plot
static QString globalUserSettigsFilename
Definition jkqtpbaseplotter.h:2782
GraphsConstIterator beginGraphs() const
returns a const iterator to the first graph
Definition jkqtpbaseplotter.h:530
QString userSettigsFilename
filename for the ini file in which to save the user settings
Definition jkqtpbaseplotter.h:2417
void zoomChangedLocally(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter *sender)
signal: emitted whenever the user selects a new x-y zoom range (in the major axes,...
void setEmittingPlotSignalsEnabled(bool __value)
controls, whether the signals plotUpdated() are emitted
QAction * getActionSavePDF() const
QAction which triggers the saving as PDF.
double mm2px(double mm, JKQTPEnhancedPainter &painter) const
returns the given size in millimeters to pixels (with given dots per inch)
Definition jkqtpbaseplotter.h:859
QAction * getActionShowPlotData() const
QAction to show a table with all the plot data in the datastore.
QAction * actSaveSVG
QAction which triggers the saving as Scalable Vector Graphics (SVG)
Definition jkqtpbaseplotter.h:2741
QString getplotLabelFontName() const
the plot label font name
double printMagnification
Definition jkqtpbaseplotter.h:2800
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...
QVector< JKQTPPlotElement * >::const_iterator GraphsConstIterator
Definition jkqtpbaseplotter.h:489
void addGraphs(const TJKQTPGraphContainer &gr, QVector< size_t > *graphIDsOut=nullptr)
add a new graphs from a QVector<JKQTPPlotElement*>, QList<JKQTPPlotElement*>, std::vector<JKQTPPlotEl...
Definition jkqtpbaseplotter.h:607
AdditionalActionsMap getLstAdditionalPlotterActions() const
this list contains additional actions, that can be registered by registerAdditionalAction()....
void saveAsCSV(const QString &filename=QString(""))
save the current plot data as a Comma Separated Values (CSV) file
void setY(double yminn, double ymaxx, bool affectsSecondaryAxes=false)
sets the y-range of the plot (minimum and maximum y-value on the y-axis)
PlotMarginSide
enum to indicate relative position from a central position
Definition jkqtpbaseplotter.h:2492
@ sideLeft
Definition jkqtpbaseplotter.h:2493
@ sideTop
Definition jkqtpbaseplotter.h:2495
@ sideRight
Definition jkqtpbaseplotter.h:2494
void moveGraphUp(int idx)
move the graph at position idx one item up (i.e. it is drawn later/higher in the z-stack)
void setGridWidth(double __value)
sets the width of all Major grid lines
double mm2px(JKQTPEnhancedPainter &painter, double mm) const
returns the given size in millimeters to pixels (with given dots per inch)
Definition jkqtpbaseplotter.h:863
void setGraphInvisible(int i)
switch visibility of the i -th graph to visible
void plotUpdated()
emitted when the plot has to be updated
QSizeF getTextSizeSize(const QFont &fm, const QString &text, QPainter &painter)
calculates a size of the given string text if it would be drawn on painter with font fm
void setAbsoluteY(double yminn, double ymaxx)
sets absolute minimum and maximum y-value to plot
GraphsIterator beginGraphs()
returns an iterator to the first graph
Definition jkqtpbaseplotter.h:549
JKQTPBaseKey::KeySizeDescription internalPlotKeyDescription
calculated value: size and location of the plot key
Definition jkqtpbaseplotter.h:2624
void setFontSizeMultiplier(double __value)
multiplier for the font size
void setBackgroundGradient(const QGradient &__value)
color of the background of the plot (widget area) when drawing (to the screen)
void printpreviewPaintRequestedNewPrinter(QPrinter *printer)
internal function for print preview
void setOnlyGraphVisible(int i)
set all graphs invisible, except i
QMap< QString, QStringList > getDataColumnsByUserSaved
Definition jkqtpbaseplotter.h:2793
void synchronizeToMaster(JKQTBasePlotter *master, SynchronizationDirection synchronizeDirection, bool synchronizeAxisLength=true, bool synchronizeZoomingMasterToSlave=true, bool synchronizeZoomingSlaveToMaster=true)
synchronize the plot borders (and zooming) with a given plotter (master --> slave/this)
QSet< int > getDataColumnsByUser()
void setWidgetHeight(int heigh)
sets the width of the plot widget
void setGraphVisible(int i, bool visible=true)
switch visibility of the i -th graph to visible
double getInternalPlotBorderLeft() const
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:1147
void moveGraphDown(int idx)
move the graph at position idx one item down (i.e. it is drawn earlier/lower in the z-stack)
QPointer< QPrintPreviewWidget > printPreview
Definition jkqtpbaseplotter.h:2802
void drawNonGrid(JKQTPEnhancedPainter &painter, const QRect &rect)
draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
double getAbsoluteXMin() const
returns the absolute x-axis min of the primary x-axis. This is the lowest allowed value the the axis ...
double getInternalPlotBorderTop() const
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:1145
void clearGridPrintingPlotters()
clear all additional plotters for grid printing mode
void draw(JKQTPEnhancedPainter &painter, const QRect &rect)
draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
AdditionalActionsMap lstAdditionalPlotterActions
this list contains additional actions, that can be registered by registerAdditionalAction()....
Definition jkqtpbaseplotter.h:2758
void setExportBackgroundTexture(const QImage &__value)
color of the background of the plot (widget area) when exporting
QMap< JKQTPCoordinateAxisRef, JKQTPHorizontalAxisBase * > getXAxes(bool includePrimary=true)
returns all available x-axes
double getAbsoluteXMax() const
returns the absolute x-axis max of the primary x-axis This is the highest allowed value the the axis ...
QString userSettigsPrefix
prefix for the ini file in which to save the user settings
Definition jkqtpbaseplotter.h:2421
void setUseAntiAliasingForText(bool __value)
specifies whether to use antialiasing when drawing any text
void setAxisAspectRatio(double __value)
sets the axis aspect ratio, enforced with setMaintainAxisApsectRatio(true)
static QString globalUserSettigsPrefix
Definition jkqtpbaseplotter.h:2783
void setBackgroundTexture(const QPixmap &__value)
color of the background of the plot (widget area) when drawing (to the screen)
const JKQTPBaseKey * getMainKey() const
retuns the main key object
void setBackgroundBrush(const QBrush &__value)
color of the background of the plot (widget area) when drawing (to the screen)
void exportpreviewPaintRequested(JKQTPEnhancedPainter &painter, QSize size)
internal function for export preview
void printpreviewSetSizeXNew(double value)
internal function for print preview
double p2x(double x) const
return x coordinate from x-pixel, using the primary axis
Definition jkqtpbaseplotter.h:878
double internalTitleHeight
calculated value: height of the plot title (or 0 if no title)
Definition jkqtpbaseplotter.h:2588
void getDataColumnsByUserCheckNone()
internal function for getDataColumnsByUser()
double getXMin() const
returns the current x-axis min of the primary x-axis
int getNextStyle()
gets the next unused style id, i.e. the smalles number >=0 which is not contained in usedStyles
QListWidget * dataColumnsListWidget
Definition jkqtpbaseplotter.h:2790
void setEmittingSignalsEnabled(bool enabled)
specifies whether this class emits signals, like zoomChangedLocally() or beforePlotScalingRecaluclate...
QAction * getActionZoomOut() const
QAction which triggers zoom out.
void moveGraphDown(const JKQTPPlotElement *gr)
move the given graph gr one item down (i.e. it is drawn earlier/lower in the z-stack)
bool hasYAxis(JKQTPCoordinateAxisRef axis=JKQTPPrimaryAxis) const
returns whether a y-axis axis is registered with the plotter
void saveAsTabSV(const QString &filename=QString(""))
save the current plot data as a Tabulator Separated Values (CSV) file
bool doesMaintainAxisAspectRatio() const
returns whether the maintaining of the axis aspect ratio is enabled or disabled
void printpreviewSetLineWidthMultiplier(double value)
internal function for print preview
QAction * actSaveCSV
QAction which triggers the saving as CSV (data only)
Definition jkqtpbaseplotter.h:2748
void resetMasterSynchronization(SynchronizationDirection synchronizeDirection=sdXYAxes)
switches any synchronization off, that has been created by synchronizeToMaster()
double internalPlotBorderTop
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:2580
int getHeight()
gets the width of the plot widget
JKQTPPen getPlotStyle(int i, JKQTPPlotStyleType type=JKQTPPlotStyleType::Default) const
returns a QPen object for the i-th plot style
void setCSVcommentInitializer(const QString &__value)
set the string used to introduce comments in text output when exporting data
QColor getPlotBackgroundColor() const
color of the plot's background (i.e. of the area within the coordinate axes rectangle)
void deleteGraph(size_t i, bool deletegraph=true)
remove the i-th graph
void getTextSizeDetail(const QString &fontName, double fontSize, const QString &text, QPainter &painter, double &width, double &ascent, double &descent, double &strikeoutPos)
calculates a text-size details for the given string text if it would be drawn on painter with font fo...
void setCSVdecimalSeparator(const QString &__value)
set the decimal separator used when exporting data to text files
QString currentPrinter
the currently selected printer
Definition jkqtpbaseplotter.h:2766
JKQTMathTextNodeSize getTextSizeDetail(const QString &fontName, double fontSize, const QString &text, QPainter &painter)
calculates a JKQTMathTextNodeSize for the given string text if it would be drawn on painter with font...
bool gridPrinting
indicates whether the grid printing is activated
Definition jkqtpbaseplotter.h:2428
QAction * actCopyPixelImage
QAction which triggers copying of the image to the clipboard.
Definition jkqtpbaseplotter.h:2734
void printpreviewUpdate()
internal function for print preview
void setPlotBackgroundTexture(const QPixmap &__value)
color of the plot's background (i.e. of the area within the coordinate axes rectangle)
bool datastoreInternal
indicates whether the datastore is managed (allocated/freed) internally or externally
Definition jkqtpbaseplotter.h:2455
JKQTPKeyPosition getKeyPosition() const
key position inside or besides the plot area, see JKQTPKeyPositions for details and examples
double fontSizeMultiplier
multiplier for the font size
Definition jkqtpbaseplotter.h:2707
QColor getBackgroundColor() const
color of the background of the plot (widget area) when drawing (to the screen)
size_t getGridPrintingCurrentX() const
x position of the current graph in grid printing
void setBackgroundColor(const QColor &__value)
color of the background of the plot (widget area) when drawing (to the screen)
void setGridPrintingCurrentPos(size_t x, size_t y)
set the x- and y-positions of this JKQTPlotter in the grid-printing grid
QAction * actPrint
QAction which triggers the printing.
Definition jkqtpbaseplotter.h:2743
void moveGraphUp(const JKQTPPlotElement *gr)
move the given graph gr one item up (i.e. it is drawn later/higher in the z-stack)
QString getDefaultTextFontName() const
default font name in the plot
double getDefaultTextSize() const
default font size in the plot [pt]
QPointer< JKQTPEnhancedDoubleSpinBox > spinSizeX
Definition jkqtpbaseplotter.h:2804
void setExportBackgroundBrush(const QBrush &__value)
color of the background of the plot (widget area) when exporting
void saveAsTabSV(const QString &filename, const QString &decimalSeparator, const QString &commentInitializer)
save the current plot data as a Tabulator Separated Values (CSV) file
bool printSetAbsolutePlotSize
Definition jkqtpbaseplotter.h:2809
bool emitPlotSignals
controls, whether the signals plotUpdated() are emitted
Definition jkqtpbaseplotter.h:2779
const JKQTPDatastore * getDatastore() const
returns a pointer to the datastore used by this object
Definition jkqtpbaseplotter.h:454
static void setDefaultJKQTBasePrinterUserSettings(QString userSettigsFilename, const QString &userSettigsPrefix)
set a global preset/default value for the userSettigsFilename and userSettigsPrefix properties of JKQ...
void saveAsSYLK(const QString &filename=QString(""))
save the current plot data as a SYmbolik LinK (SYLK) spreadsheet file (see https://en....
static void deregisterPaintDeviceAdapter(JKQTPPaintDeviceAdapter *adapter)
de-register a JKQTPPaintDeviceAdapter from JKQTBasePlotter/JKQTPlotter
QString getCurrentFileFormat() const
return the last file format to use in SaveAs ... dialogs
JKQTPHorizontalAxis * xAxis
object used for the x-axis
Definition jkqtpbaseplotter.h:2403
void printpreviewSetKeepAbsFontsize(bool checked)
internal function for print preview
void setPlotBorderLeft(int left)
sets the left border of the plot
JKQTPVerticalAxisBase * getYAxis(JKQTPCoordinateAxisRef axis=JKQTPPrimaryAxis)
returns the y-axis objet of the plot
bool isEmittingPlotSignalsEnabled() const
returns, whether the signals plotUpdated() are emitted
int getPlotBorderBottom() const
free space between widget bottom border and plot bottom border, this property may be set by the user ...
void setUserSettigsFilename(const QString &filename)
set filename, used by loadUserSettings() and saveUserSettings()
void moveGraphTop(int idx)
move the given graph to the top
void setPlotLabelColor(QColor __value)
the plot label color
void setGridStyle(Qt::PenStyle __value)
sets the style of all Major grid lines
bool isDebugShowRegionBoxesEnabled() const
if set true (default: false ) the JKQTBasePlotter draws colored rectangles to indicate the different ...
JKQTBasePlotter()=delete
bool exportUnitInMM
Definition jkqtpbaseplotter.h:2814
bool getGraphsXMinMax(double &minx, double &maxx, double &smallestGreaterZero, const PlotElementPreciate &predicate=allPlotElements())
get the maximum and minimum x-value over all graphs in the plot
double printAspect
Definition jkqtpbaseplotter.h:2812
QList< size_t > gridPrintingColumns
this list contains all the columns of the current grid printing and stores its widths
Definition jkqtpbaseplotter.h:2444
QAction * actZoomAll
QAction which triggers zoom all.
Definition jkqtpbaseplotter.h:2750
void setCurrentSaveDirectory(const QString &__value)
sets the current directory in which to open SaveAs ... dialogs
JKQTBasePlotter(bool datastore_internal, QObject *parent=nullptr, JKQTPDatastore *datast=nullptr)
class constructor
bool printpreviewNew(QPaintDevice *paintDevice, bool setAbsolutePaperSize=false, double printsizeX_inMM=-1.0, double printsizeY_inMM=-1.0, bool displayPreview=true)
show the print preview window for a given print p
void afterPrinting()
emitted just before Printing the current plot as image, or just before the print preview dialog is sh...
void getDataColumnsByUserItemChanged(QListWidgetItem *widgetitem)
internal function for getDataColumnsByUser()
void saveAsSemicolonSV(const QString &filename, const QString &decimalSeparator, const QString &commentInitializer)
save the current plot data as a Semicolon Separated Values (SSV) file
void redrawPlot()
emit plotUpdated(), which can be used by e.g. a widget class to update the displayed plot
Definition jkqtpbaseplotter.h:995
void printpreviewSetAspectRatio(bool checked)
internal function for print preview
void getDataColumnsByUserSave()
internal function for getDataColumnsByUser()
QSizeF printPageSizeMM
Definition jkqtpbaseplotter.h:2815
double lineWidthMultiplier
multiplier or the line widths
Definition jkqtpbaseplotter.h:2709
double getLineWidthMultiplier() const
multiplier or the line widths
size_t getGraphCount() const
returns the number of graphs
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.
QAction * getActionSaveData() const
QAction which triggers saving of the data used for the plot.
static JKQTPSynchronized< QList< JKQTPPaintDeviceAdapter * > > jkqtpPaintDeviceAdapters
Definition jkqtpbaseplotter.h:2785
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...
double lineWidthPrintMultiplier
multiplier which is used for linewidths when the plot is exported/printed
Definition jkqtpbaseplotter.h:2704
double getAbsoluteYMin() const
returns the absolute y-axis min of the primary y-axis This is the lowest allowed value the the axis m...
void drawSystemGrid(JKQTPEnhancedPainter &painter)
plot the grid
JKQTPCoordinateAxisRef addSecondaryXAxis(JKQTPHorizontalAxisBase *axis)
adds a secondary x-axis
void setFontSizePrintMultiplier(double __value)
multiplier which is used for font sizes when the plot is exported/printed
void setCurrentPlotterStyle(const JKQTBasePlotterStyle &style)
replace the current style properties for this JKQTBasePlotter
void updateSecondaryAxes()
updates the secondary axes
void setX(double xminn, double xmaxx, bool affectsSecondaryAxes=false)
sets the x-range of the plot (minimum and maximum x-value on the x-axis)
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)
JKQTPBaseKey * getMainKey()
retuns the main key object
void printpreviewSetMagnification(double value)
internal function for print preview
void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTBasePlotter *sender)
may be connected to zoomChangedLocally() of a different plot and synchronizes the local x- and y-axis...
QAction * getActionZoomAll() const
QAction which triggers zoom all.
void setMinorGridStyle(Qt::PenStyle __value)
sets the style of all minor grid lines
GraphsConstIterator endGraphs() const
returns a const iterator behind the last graph
Definition jkqtpbaseplotter.h:534
const JKQTPGraphsModel * getPlotsModel() const
returns model representing all Plots in this plotter and showing their visible/invisible state
Definition jkqtpbaseplotter.h:492
bool hasXAxis(JKQTPCoordinateAxisRef axis=JKQTPPrimaryAxis) const
returns whether an x-axis axis is registered with the plotter
void copyPixelImage(bool showPreview=true)
copy the current plot as a pixel+svg image to the clipboard
void drawKey(JKQTPEnhancedPainter &painter)
plot a key
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...
void setplotLabelFontName(const QString &__value)
the plot label font name
void saveAsSemicolonSV(const QString &filename=QString(""))
save the current plot data as a Semicolon Separated Values (SSV) file
void addGridPrintingPlotter(size_t x, size_t y, JKQTBasePlotter *plotter)
add a new plotter for grid printing mode
void zoomOut(double factor=2.0)
zooms out of the graph (the same as turning the mouse wheel) by the given factor
void synchronizeYToMaster(JKQTBasePlotter *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...
QVector< JKQTPPlotElement * >::iterator GraphsIterator
Definition jkqtpbaseplotter.h:488
void setAllGraphsInvisible()
set all graphs in the plotter invisible
double didot2px(double pt, double dpi) const
returns the given size in Didot points (0.376 mm) to pixels (with given dots per inch)
Definition jkqtpbaseplotter.h:829
double printZoomFactor
Definition jkqtpbaseplotter.h:2797
double getFontSizePrintMultiplier() const
multiplier which is used for font sizes when the plot is exported/printed
double getPrintMagnification() const
void setPaintMagnification(double __value)
this is an internal property that is used by the export/print system to control the "magnification"....
double getFontSizeMultiplier() const
multiplier for the font size
int getPlotHeight() const
calculated value: plot height in pixel inside the widget (calculated by calcPlotScaling() from plotBo...
Definition jkqtpbaseplotter.h:1155
JKQTPCoordinateAxisRef addSecondaryYAxis(JKQTPVerticalAxisBase *axis)
adds a secondary y-axis
QColor getExportBackgroundColor() const
color of the background of the plot (widget area) when exporting
bool printSetAbsolutePageSize
Definition jkqtpbaseplotter.h:2808
void copyData()
copy the data used for the current plot to the clipboard
void setLineWidthMultiplier(double __value)
multiplier or the line widths
bool getShowKey() const
indicates whether to plot a key
const JKQTPKeyStyle & getMainKeyStyle() const
retuns the JKQTPKeyStyle to be used for the main key (extracted from JKQTBasePlotterStyle::keyStyle)
QAction * actCopyData
QAction which triggers copying of the data to the clipboard.
Definition jkqtpbaseplotter.h:2732
void afterExporting()
emitted just before exporting the current plot as image, or just before the export preview dialog is ...
QAction * getActionPrint() const
QAction which triggers the printing.
size_t gridPrintingCurrentX
x position of the current graph in grid printing
Definition jkqtpbaseplotter.h:2433
void draw(JKQTPEnhancedPainter &painter, const QPoint &pos=QPoint(0, 0))
draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
void setExportBackgroundColor(const QColor &__value)
color of the background of the plot (widget area) when exporting
GraphsIterator endGraphs()
returns an iterator behind the last graph
Definition jkqtpbaseplotter.h:556
double getPaintMagnification() const
this is an internal property that is used by the export/print system to control the "magnification"....
PlotMarginUse
used for calculated value:describing what freespace outside the graph area is used for
Definition jkqtpbaseplotter.h:2478
@ muPlotTitle
Definition jkqtpbaseplotter.h:2481
@ muUsesCount
Definition jkqtpbaseplotter.h:2488
@ muAxesOutside
Definition jkqtpbaseplotter.h:2485
@ muKey
Definition jkqtpbaseplotter.h:2482
@ muAxesOutsideExtend
Definition jkqtpbaseplotter.h:2484
@ muGraphsOutside
Definition jkqtpbaseplotter.h:2483
static JKQTPSynchronized< QList< JKQTPSaveDataAdapter * > > jkqtpSaveDataAdapters
Definition jkqtpbaseplotter.h:2786
void saveUserSettings() const
saves the plot user properties to the file sepcified by setUserSettigsFilename() and the prefix speci...
void enableDebugShowRegionBoxes(bool enabled=true)
if set true (default: false ) the JKQTBasePlotter draws colored rectangles to indicate the different ...
const JKQTBasePlotterStyle & getCurrentPlotterStyle() const
current style properties for this JKQTBasePlotter
QAction * getActionSavePix() const
QAction which triggers the saving as pixel image.
double getInternalPlotBorderBottom() const
calculated value: free space between widget top border and plot top border, as used to plot the graph
Definition jkqtpbaseplotter.h:1149
static bool deregisterSaveDataAdapter(JKQTPSaveDataAdapter *adapter)
de-register a JKQTPSaveDataAdapter from JKQTPlotter/JKQTBasePlotter
bool maintainAspectRatio
indicates whether the widget should maintain an aspect ratio of plotwidth and plotheight
Definition jkqtpbaseplotter.h:2649
GraphsList graphs
a vector that contains all graphs to be plottet in the system
Definition jkqtpbaseplotter.h:2716
QString plotLabel
the plot label text
Definition jkqtpbaseplotter.h:2687
bool containsGraph(const JKQTPPlotElement *gr) const
returns true, if the given graph is in this plot
void setPlotBackgroundBrush(const QBrush &__value)
color of the plot's background (i.e. of the area within the coordinate axes rectangle)
void deregisterAdditionalAction(QAction *act)
this function deregisters an additional action, previously added with registerAdditionalAction()
bool getGridPrinting() const
indicates whether the grid printing is activated
double getPlotFrameRounding() const
if plotFrameVisible==true, JKQTBasePlotter will draw a rectangle/frame around the plot,...
void setPlotBorderRight(int right)
sets the right border of the plot
QAction * getActionCopyMatlab() const
QAction which triggers copying of the data to the clipboard in Matlab format.
bool getMasterSynchronizeHeight() const
synchronize plot height with masterPlotterY
GraphsConstIterator cendGraphs() const
returns a const iterator behind the last graph
Definition jkqtpbaseplotter.h:542
QAction * actSaveData
QAction which triggers saving of the data used for the plot.
Definition jkqtpbaseplotter.h:2730
void drawNonGrid(JKQTPEnhancedPainter &painter, const QPoint &pos=QPoint(0, 0))
draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter
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 ...
QString getCSVcommentInitializer() const
set the string used to introduce comments in text output when exporting data
QComboBox * dataColumnsCombobox
Definition jkqtpbaseplotter.h:2791
double p2y(double y) const
return y coordinate from y-pixel, using the primary axis
Definition jkqtpbaseplotter.h:883
bool getMasterSynchronizeWidth() const
synchronize plot width with masterPlotterX
QMap< JKQTPCoordinateAxisRef, JKQTPVerticalAxisBase * > secondaryYAxis
objects used a secondary y-axes
Definition jkqtpbaseplotter.h:2409
void loadUserSettings()
loads the plot user properties from the file sepcified by setUserSettigsFilename() and the prefix spe...
void setGridPrinting(bool __value)
indicates whether the grid printing is activated
JKQTPGraphsModel * getPlotsModel()
returns model representing all Plots in this plotter and showing their visible/invisible state
Definition jkqtpbaseplotter.h:495
void drawGraphs(JKQTPEnhancedPainter &painter)
plot the graphs in the order they appear in the list graphs, i.e. initially the order of the addGraph...
void moveGraphBottom(int idx)
move the given graph to the top
QMap< QString, QList< QPointer< QAction > > > AdditionalActionsMap
Definition jkqtpbaseplotter.h:397
Support Class for JKQTBasePlotter, which summarizes all properties that define the visual styling of ...
Definition jkqtpbaseplotterstyle.h:47
Support Class for JKQTBasePlotter, which summarizes a fill style.
Definition jkqtpgraphsbasestyle.h:47
this class parses a mathematical markup string and can then draw the contained text/equation onto a Q...
Definition jkqtmathtext.h:192
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
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
this virtual base class of the (data-column based) graphs, which are part of a JKQTPlotter plot and w...
Definition jkqtpgraphsbase.h:429
data model with all plots ina JKQTBasePlotter (+ allows to switch them visible/invisible)
Definition jkqtpgraphsmodel.h:41
base class for horizontal axes, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoo...
Definition jkqtpcoordinateaxes.h:1154
implements a horizontal axis, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoord...
Definition jkqtpcoordinateaxes.h:1221
Support Class for JKQTBasePlotter, which summarizes all properties that define the visual styling of ...
Definition jkqtpkeystyle.h:49
concrete class for drawing the main plot key (or legend). This class reads the key entries from the g...
Definition jkqtpkey.h:362
Service from this class to implement a special QPaintDevice as a plugin, that can be registered to JK...
Definition jkqtpbaseplotter.h:89
virtual double getPrintSizeXInMM() const =0
virtual QString getFilter() const =0
Filter-String for a Qt File-Dialog, e.g. "JPEG Files (*.jpg)"
virtual QString getFormatName() const =0
Human readable name for the format.
virtual ~JKQTPPaintDeviceAdapter()
Definition jkqtpbaseplotter.h:91
virtual double getPrintSizeYInMM() const =0
virtual QString getFormatID() const =0
a plugin-ID, i.e. a unique name for this format plugin, e.g. MyPluginExport_JPEG
virtual QStringList getFileExtension() const =0
returns a list (in lower-case) of the file extensions supported by this plugin, e....
virtual bool getSetAbsolutePaperSize() const =0
virtual QPaintDevice * createPaintdevice(const QString &filename, int widthPix, int heightPix) const =0
create a paint device with a given size in pt
virtual QPaintDevice * createPaintdeviceMM(const QString &filename, double widthMM, double heightMM) const
create a paint device with a given size in millimeters ... the default implementation call createPain...
virtual bool isPrinter() const =0
this virtual base class of every element, which is part of a JKQTPlotter plot and may appear in its k...
Definition jkqtpgraphsbase.h:62
virtual base-class for exporter classes that can be used to save data inot a file
Definition jkqtpbaseplotter.h:72
virtual QStringList getFileExtension() const =0
returns a list (in lower-case) of the file extensions supported by this plugin, e....
virtual ~JKQTPSaveDataAdapter()
virtual QString getFormatID() const =0
a plugin-ID, i.e. a unique name for this format plugin, e.g. MyPluginExport_MATLABMAT
virtual void saveJKQTPData(const QString &filename, const QList< QVector< double > > &data, const QStringList &columnNames) const =0
actually save the table data into file filename . The parameter columnNames provides a name for each ...
virtual QString getFilter() const =0
Filter-String for a Qt File-Dialog, e.g. "CSV Files (*.csv)"
template class that wraps any datatype and combines it with a mutex, exposes the lock()/unlock() inte...
Definition jkqtpconcurrencytools.h:40
base class for vertical axes, based on JKQTPCoordinateAxis (for most of documentation: see JKQTPCoord...
Definition jkqtpcoordinateaxes.h:967
implements a vertical axis for use as primary, secondary, ... axis of a JKQTPBasePlotter,...
Definition jkqtpcoordinateaxes.h:1032
JKQTPCoordinateAxes
named references for different oordinate axes in the plot
Definition jkqtpcoordinateaxes.h:42
QFlags< JKQTPKeyPositions > JKQTPKeyPosition
position of the key
Definition jkqtptools.h:607
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89
JKQTPPlotStyleType
used to specify teh type of graph when calling getPlotStyle()
Definition jkqtptools.h:68
JKQTPLOTTER_LIB_EXPORT void initJKQTBasePlotterResources()
initialized Qt-ressources necessary for JKQTBasePlotter
size_t qHash(const JKQTBasePlotter::textSizeKey &data, size_t)
qHash()-specialization
Definition jkqtpbaseplotter.h:2828
@ JKQTPPrimaryAxis
Definition jkqtpcoordinateaxes.h:43
JKQTPGraphSymbols
symbols that can be used to plot a datapoint for a graph
Definition jkqtpdrawingtools.h:143
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
used for calculated value: describing a section in the freespace outside the graph area
Definition jkqtpbaseplotter.h:2502
PlotMargin(double l=0, double r=0, double t=0, double b=0)
Definition jkqtpbaseplotter.h:2508
double getMargin(PlotMarginSide side) const
select left,right, top, bottom, depending on side
Definition jkqtpbaseplotter.h:2511
double right
Definition jkqtpbaseplotter.h:2504
double left
Definition jkqtpbaseplotter.h:2503
double bottom
Definition jkqtpbaseplotter.h:2506
double top
Definition jkqtpbaseplotter.h:2505
Functor which does not apply any filter to JKQTPPlotElement, e.g. in getGraphsXMinMax() or getGraphsY...
Definition jkqtpbaseplotter.h:655
bool operator()(const JKQTPPlotElement *) const
Definition jkqtpbaseplotter.h:656
filter functor which accepts only those JKQTPPlotElement where JKQTPPlotElement::getXAxisRef() return...
Definition jkqtpbaseplotter.h:663
bool operator()(const JKQTPPlotElement *el) const
filterPlotElementByXAxis(JKQTPCoordinateAxisRef ref_)
Definition jkqtpbaseplotter.h:664
JKQTPCoordinateAxisRef ref
Definition jkqtpbaseplotter.h:667
filter functor which accepts only those JKQTPPlotElement where JKQTPPlotElement::getYAxisRef() return...
Definition jkqtpbaseplotter.h:674
JKQTPCoordinateAxisRef ref
Definition jkqtpbaseplotter.h:678
bool operator()(const JKQTPPlotElement *el) const
filterPlotElementByYAxis(JKQTPCoordinateAxisRef ref_)
Definition jkqtpbaseplotter.h:675
internal tool class for text-sizess in a plot key
Definition jkqtpbaseplotter.h:1413
int ldpiX
Definition jkqtpbaseplotter.h:1418
textSizeKey(const QString &fontName, double fontSize, const QString &text, QPaintDevice *pd)
QString text
Definition jkqtpbaseplotter.h:1416
QFont f
Definition jkqtpbaseplotter.h:1417
bool operator==(const textSizeKey &other) const
textSizeKey(const QFont &f, const QString &text, QPaintDevice *pd)
beschreibt die Größe(n) eines Knotens
Definition jkqtmathtexttools.h:393
struct, describing basic layout and size properties of a key/legend, mostly used as return value of g...
Definition jkqtpkey.h:119