/* Copyright (c) 2008-2018 Jan W. Krieger () This software is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License (LGPL) for more details. You should have received a copy of the GNU Lesser General Public License (LGPL) along with this program. If not, see . */ /** * \defgroup jkqtpbaseplotter Plotter Base Class * \ingroup jkqtplotter * * * This class implements the basis for plotter classes. It contains layout management code, * coordinate system management ... Use JKQPlotter if you need a widget */ /** \file jkqtpbaseplotter.h * \ingroup jkqtpbaseplotter */ #include "jkqtplottertools/jkqtptools.h" #include "jkqtplotter/jkqtpdatastorage.h" #include "jkqtmathtext/jkqtmathtext.h" #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtpelementsoverlay.h" #include "jkqtplottertools/jkqtpenhancedpainter.h" #include "jkqtplottergui/jkqtpenhancedspinboxes.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "jkqtplottertools/jkqtp_imexport.h" #ifndef JKQTPBASEPLOTTER_H #define JKQTPBASEPLOTTER_H class JKQTPgraphsModel; // forward class JKQTPgraph; // forward class JKQTPplotElement; // forward /** \brief initialized Qt-ressources necessary for JKQtBasePlotter */ LIB_EXPORT void initJKQtBasePlotterResources(); /** \brief base class for 2D plotter classes * \ingroup jkqtplotter * * This class implements basic functionalities for the plotter classes. Those are: * -# data storage using a JKQTPdatastore object * -# coordinate transforms * -# a set of properties for the graphs (colors, widthes ...) and also a system (see getNextStyle() to automatically * choose a drawing style for different graphs. * -# plot a set of overlay elements (may be used for fast plotting of indicators onto a complex plot) * -# drawing the coordinate axes, grids ... (logarithmic and linear) * -# saveing and printing the resulting plots * . * * This class is NOT a widget, if you need a plotting widget, use JKQtPlotter. This class may be used to * plot onto any JKQTPEnhancedPainter. * * * * \section jkqtplotter_base_datastore Data Storage * As already mentioned this class does not provide means to draw graphs, but it contains a basic mechanism to associate * data with it. This is imeplemented, using a JKQTPdatastore object together with some convenience access methods. No further * data access is implemented and child classes are NOT forced to use this datastore. Hide it if you want. JKQtPlotter shows * how to use it. This class implement a graph management, where graphs simply point to a set of columns inside the datastore * that contain the actual plot data! * * If you call the \link JKQtPlotterBase::JKQtPlotterBase() constructor \endlink with no arguments, it will create an internal * datastore object and you can start adding data by using get_datastore(). If you have an external JKQTPdatastore object you can * give it as parameter to the constructor or use one of the other methods: * - useExternalDatastore(): \copybrief JKQtPlotterBase::useExternalDatastore() * - useAsInternalDatastore(): \copybrief JKQtPlotterBase::useAsInternalDatastore() * - useInternalDatastore(): \copybrief JKQtPlotterBase::useInternalDatastore() * - forceInternalDatastore(): \copybrief JKQtPlotterBase::forceInternalDatastore() *. * * * * \section jkqtplotter_base_systems Coordinate Systems and Transformations * These topics are discussed in the help for JKQTPcoordinateAxis. There is a set of coordinate transform * methods (x2p(), y2p(), p2x(), p2y() which only call the respective methods in xAxis and yAxis objects. * * * \section jkqtplotter_base_grids Axis Ticks and Grids * - The plotting of coordinate axes and grids, as well as coordinate transforms is done by * JKQTPcoordinateAxis descendents (see documentation there) * . * If you want to set the axis properties, use get_xAxis() or get_yAxis() to get a pointer to the axis objects which then * may be used to set the axis properties. * * * \section jkqtplotter_base_key Graph Keys * 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 * implemented by child classes, as no graph management, that could provide a title for a specific graph, is implemented here. Key Plotting is * performed in the plotKey() method. This method basically draws a frame and background and then calls plotKeyContent() to draw the actual contents. * 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. * 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 * 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 * in child classes. * * \image html plot_key.png * * 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 * 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 * 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 * Note that the margin change is internal and not visible in the class interface! * * 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. If this * 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 * key content. By default this feature is switched ON. * * * \section jkqtplotter_base_saveprint Saving and Printing Graphs * This class implement a set of function to save and print the graphs: * - print() prints the graph on a QPrinter object * - saveAsPixelImage() saves the plot into a pixel image file (PNG, TIFF, ... formats, as supported by Qt) * - saveAsPDF() saves the graph as a PDF file (using the Qt printing engine) * - saveAsPS() saves the graph as a PDF file (using the Qt printing engine) * - saveAsSVG() saves the graph as a SVG file (using the Qt SVG library) * - saveAsCSV() saves the data of the plot as comma separated values * - saveAsSYLK() saves the data of the plot as SYLK spreadsheet * - saveAsDIF() saves the data of the plot as data interchange format file * . * * As one often want's to combine different graphs, there is a possibility to combine this graph with more other graphs. * To do so one can think of the graphs to be part of a grid where each graph is contained in one cell. By default this * mechanism is deactivated. You can activate it by calling set_gridPrinting(true). Then you can set the position of the * current graph by calling set_gridPrintingCurrentX() and set_gridPrintingCurrentY(). Add additional graphs by calling * addGridPrintingPlotter(). The position of the current graph is 0,0 by default. Afterwards the save and print routines * will export/print all graphs, not just the current one. There will be no additional border between the graphs, as the * class expects the internal graph borders to be sufficient. * * * \section jkqtplotter_base_defaultvalues Default Properties * The plot is configured by a huge set of properties. For each property there is also a second protected variable which * contains its default value. This way it is possible to store only those parameters in an INI file which have changed with * respect to the default values. If the property is called \c property then the according default value is stored in * \c def_property. To reduce the code to be entered you can use the JKQTPPROPERTY() macro. * * Default values are available only for properties that control the appearance of the graphs (line widths, border widths, * color, fonts ...), not the type of the graph (xmin, xmax, logXAxis, ...) * * \section jkqtplotter_base_userprops User Properties * There is a subset of options that describe how the user interacted with the plotter (export/print scaling factors etc, save directories, * other export settings, ...). These are not stored/loaded using saveSettings() and loadSettings(), but using saveUserSettings() and loadUserSettings(). * These methods MAY (strictly optional and turned off by default) be called by saveSettings() and loadSettings(), if the property userSettigsFilename is * set (not-empty). In this case the suer settings are stored/loaded also everytime they are changed by the user or programmatically. * * \section jkqtplotter_base_aspectratios Aspect Ratios * First note that this functionality is only available and activated if both axes are linear! * * You can set two different aspect ratios: * - The ratio of plotWidth/plotHeight (set_aspectRatio(), set_maintainAspectRatio()) will keep the plots pixel-width and height at a certain value. * - The ratio of (xmax-xmin)/(ymax-ymin) (set_axisAspectRatio(), set_maintainAxisAspectRatio()) will keep the displayed axis ranges in a certain ratio. * . * So to achieve different effects, use these combinations: * - you have a 200x100 range where each 1x1-pixel should have an aspect ratio of 4: * \code * set_aspectRatio(200.0/100.0); * set_axisAspectRatio(4.0*get_aspectRatio()); * \endcode * . */ class LIB_EXPORT JKQtBasePlotter: public QObject { Q_OBJECT public: typedef QMap > > AdditionalActionsMap; typedef QMapIterator > > AdditionalActionsMapIterator; protected: /** \brief used to plot LaTeX markup */ JKQTmathText mathText; /** \brief model representing all Plots in this plotter and showing their visible/invisible state */ JKQTPgraphsModel* m_plotsModel; /** \brief object used for the x-axis */ JKQTPhorizontalAxis* xAxis; /** \brief object used for the y-axis */ JKQTPverticalAxis* yAxis; /** \brief filename for the ini file in which to save the user settings * \see jkqtplotter_base_userprops */ QString userSettigsFilename; /** \brief prefix for the ini file in which to save the user settings * \see jkqtplotter_base_userprops */ QString userSettigsPrefix; /** \brief indicates whether the \ref jkqtplotter_base_saveprint is activated .*/ bool gridPrinting; /** \brief x position of the current graph in \ref jkqtplotter_base_saveprint */ size_t gridPrintingCurrentX; /** \brief y position of the current graph in \ref jkqtplotter_base_saveprint */ size_t gridPrintingCurrentY; /** \brief list that manages all the additional graphs for grid printing mode */ QList gridPrintingList; /** \brief this list contains all the rows of the current printing grid and stores its heights */ QList gridPrintingRows; /** \brief this list contains all the columns of the current printing grid and stores its widths */ QList gridPrintingColumns; /** \brief size of all plots in grid printing mode, filled by gridPrintingCalc() */ QSizeF gridPrintingSize; /** \brief this is an internal property that is used by the export/print system to control the "magnification". Usually this is 1.0 * but if set !=1.0, it is used to scale the widgetWidth and widgetHeight before painting! */ double paintMagnification; /** \brief the decimal separator used when exporting data to text files */ QString CSVdecimalSeparator; /** \brief default value for property property varname. \see CSVdecimalSeparator for more information */ QString def_CSVdecimalSeparator; /** \brief this string is used to introduce comments in text output when exporting data */ QString CSVcommentInitializer; /** \brief default value for property property varname. \see CSVcommentInitializer for more information */ QString def_CSVcommentInitializer; /** \brief an object which manages all data columns for this plotter class */ JKQTPdatastore* datastore; /** \brief indicates whether the datastore is managed (allocated/freed) internally or externally */ bool datastoreInternal; /** \brief width of the plot widget */ int widgetWidth; /** \brief height of the plot widget */ int widgetHeight; /** \brief free space between widget top border and plot top border, this property may be set by the user and is possibly altered * by the key positioning algorithm. The altered value is written to iplotBorderTop */ int plotBorderTop; /** \brief default value for property property varname. \see plotBorderTop for more information */ int def_plotBorderTop; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ int iplotBorderTop; int iplotKeyBorderTop; /** \brief height of the plot title (or 0 if no title) */ int iTitleHeight; /** \brief free space between widget left border and plot left border, this property may be set by the user and is possibly altered * by the key positioning algorithm. The altered value is written to iplotBorderLeft */ int plotBorderLeft; /** \brief default value for property property varname. \see plotBorderLeft for more information */ int def_plotBorderLeft; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ int iplotBorderLeft; int iplotKeyBorderLeft; /** \brief free space between widget bottom border and plot bottom border, this property may be set by the user and is possibly altered * by the key positioning algorithm. The altered value is written to iplotBorderBottom */ int plotBorderBottom; /** \brief default value for property property varname. \see plotBorderBottom for more information */ int def_plotBorderBottom; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ int iplotBorderBottom; int iplotKeyBorderBottom; /** \brief free space between widget right border and plot right border, this property may be set by the user and is possibly altered * by the key positioning algorithm. The altered value is written to iplotBorderRight */ int plotBorderRight; /** \brief default value for property property varname. \see plotBorderRight for more information */ int def_plotBorderRight; /** \brief free space between widget top border and plot top border, as used to plot the graph (mnay be altered from user input ) */ int iplotBorderRight; int iplotKeyBorderRight; /** \brief free space between widget top border and plot top border (including coordinate axes) */ int iplotBorderTop_nographs; /** \brief free space between widget left border and plot left border (including coordinate axes) */ int iplotBorderLeft_nographs; /** \brief free space between widget right border and plot right border (including coordinate axes) */ int iplotBorderBottom_nographs; /** \brief free space between widget bottom border and plot bottom border (including coordinate axes) */ int iplotBorderRight_nographs; /** \brief indicates whether the widget should maintain an aspect ratio of plotwidth and plotheight */ bool maintainAspectRatio; /** \brief default value for property property varname. \see maintainAspectRatio for more information */ bool def_maintainAspectRatio; /** \brief the aspect ratio of plotwidth and plotheight to maintain, if \c maintainAspectRatio==true */ double aspectRatio; /** \brief default value for property property varname. \see aspectRatio for more information */ double def_aspectRatio; /** \brief indicates whether the axes should maintain an aspect ratio */ bool maintainAxisAspectRatio; /** \brief default value for property property varname. \see maintainAxisAspectRatio for more information */ bool def_maintainAxisAspectRatio; /** \brief the aspect ratio of axis widths to maintain, if \c maintainAxisAspectRatio==true */ double axisAspectRatio; /** \brief default value for property property varname. \see axisAspectRatio for more information */ double def_axisAspectRatio; /** \brief plot width in pixels inside the widget (calculated by calcPlotScaling() from plotBorderLeft, plotBorderRight and widgetWidth) */ int plotWidth; /** \brief plot height in pixels inside the widget (calculated by calcPlotScaling() from plotBorderTop, plotBorderBottom and widgetHeight) */ int plotHeight; /** \brief color of the plotted graph */ QColor graphColor; /** \brief default value for property property varname. \see graphColor for more information */ QColor def_graphColor; /** \brief colors used in modes where more than one graph is beeing plottet */ QColor manyGraphsColor[50]; QColor def_manyGraphsColor[50]; /** \brief number of actually defined items in manyGraphsColor */ int manyGraphsColorCount; /** \brief pen styles used in modes where more than one graph is beeing plottet */ Qt::PenStyle manyGraphsStyle[5]; /** \brief default value for property property varname. \see manyGraphsStyle[5] for more information */ Qt::PenStyle def_manyGraphsStyle[5]; /** \brief width of the plotted graph (in pixel) */ double graphWidth; /** \brief default value for property property varname. \see graphWidth for more information */ double def_graphWidth; /** \brief indicates whether to use clipping (hack for printing, see print() ) */ bool useClipping; /** \brief color of the coordinate system */ QColor systemColor; /** \brief default value for property property varname. \see systemColor for more information */ QColor def_systemColor; /** \brief width of the coordinate (in pixel) */ double systemWidth; /** \brief default value for property property varname. \see systemWidth for more information */ double def_systemWidth; /** \brief color of the background*/ QColor backgroundColor; /** \brief default value for property property varname. \see backgroundColor for more information */ QColor def_backgroundColor; /** \brief color of the background when exporting*/ QColor exportBackgroundColor; /** \brief default value for property property varname. \see exportBackgroundColor for more information */ QColor def_exportBackgroundColor; /** \brief color of the plot's background*/ QColor plotBackgroundColor; /** \brief default value for property property varname. \see plotBackgroundColor for more information */ QColor def_plotBackgroundColor; /** \brief indicates whether to plot a frame around the key */ bool showKeyFrame; /** \brief default value for property property varname. \see showKeyFrame for more information */ bool def_showKeyFrame; /** \brief color of the key frame line */ QColor keyFrameColor; /** \brief default value for property property varname. \see keyFrameColor for more information */ QColor def_keyFrameColor; /** \brief width of the key frame line */ double keyFrameWidth; /** \brief default value for property property varname. \see keyFrameWidth for more information */ double def_keyFrameWidth; /** \brief color of the key background */ QColor keyBackgroundColor; /** \brief default value for property property varname. \see keyBackgroundColor for more information */ QColor def_keyBackgroundColor; /** \brief indicates whether to plot a key */ bool showKey; /** \brief default value for property property varname. \see showKey for more information */ bool def_showKey; /** \brief font face for key labels */ QString keyFont; /** \brief default value for property property varname. \see keyFont for more information */ QString def_keyFont; /** \brief font size for key labels [in points] */ double keyFontSize; /** \brief default value for property property varname. \see keyFontSize for more information */ double def_keyFontSize; /** \brief width of a key item in pixels [in units of width of 'X' set in keyFont, keyFontSize] */ double key_item_width; /** \brief default value for property property varname. \see key_item_width for more information */ double def_key_item_width; /** \brief height of a key item in pixels [in units of height keyFont, keyFontSize] */ double key_item_height; /** \brief default value for property property varname. \see key_item_height for more information */ double def_key_item_height; /** \brief length of the line samples in the key in pixels [in units of width of 'X' set in keyFont, keyFontSize] */ double key_line_length; /** \brief default value for property property varname. \see key_line_length for more information */ double def_key_line_length; /** \brief x-distance between key frame and key content [in units of width of 'X' set in keyFont, keyFontSize] */ double keyXMargin; /** \brief default value for property property varname. \see keyXMargin for more information */ double def_keyXMargin; /** \brief y-distance between key frame and key content [in units of width of 'x' set in keyFont, keyFontSize] */ double keyYMargin; /** \brief default value for property property varname. \see keyYMargin for more information */ double def_keyYMargin; /** \brief x-offset of the key from the border of the plot [in units of width of 'X' set in keyFont, keyFontSize] */ double keyXOffset; /** \brief default value for property property varname. \see keyXOffset for more information */ double def_keyXOffset; /** \brief y-offset of the key from the border of the plot [in units of width of 'x' set in keyFont, keyFontSize] */ double keyYOffset; /** \brief default value for property property varname. \see keyYOffset for more information */ double def_keyYOffset; /** \brief distance between key line example and key text [in units of width of 'X' set in keyFont, keyFontSize] */ double keyXSeparation; /** \brief default value for property property varname. \see keyXSeparation for more information */ double def_keyXSeparation; /** \brief distance between two key entries [in units of height of keyFont, keyFontSize] */ double keyYSeparation; /** \brief default value for property property varname. \see keyYSeparation for more information */ double def_keyYSeparation; /** \brief key position */ JKQTPkeyPosition keyPosition; /** \brief default value for property property varname. \see keyPosition for more information */ JKQTPkeyPosition def_keyPosition; /** \brief the key layout */ JKQTPkeyLayout keyLayout; /** \brief default value for property property varname. \see keyLayout for more information */ JKQTPkeyLayout def_keyLayout; /** \brief determine width of the key automatically */ bool keyAutosize; /** \brief default value for property property varname. \see keyAutosize for more information */ bool def_keyAutosize; /** \brief the plot label text */ QString plotLabel; /** \brief the plot label font name */ QString plotLabelFontname; /** \brief default value for property property varname. \see plotLabelFontname for more information */ QString def_plotLabelFontname; /** \brief the plot label font size */ double plotLabelFontSize; /** \brief default value for property property varname. \see plotLabelFontSize for more information */ double def_plotLabelFontSize; /** \brief calculate the scaling and offset values from axis min/max values */ void calcPlotScaling(JKQTPEnhancedPainter& painter); /** \brief set the standard settings (colors, line widths ...) */ void initSettings(); /** \brief specifies whether this class emits signals, like zoomChangedLocally() */ bool emitSignals; /** \brief specifies whether to use antialiasing for plotting the coordinate system */ bool useAntiAliasingForSystem; /** \brief default value for property property varname. \see useAntiAliasingForSystem for more information */ bool def_useAntiAliasingForSystem; /** \brief specifies whether to use antialiasing for plotting the graphs * * \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a * roughly three-fold speed improvement! */ bool useAntiAliasingForGraphs; /** \brief default value for property property varname. \see useAntiAliasingForGraphs for more information */ bool def_useAntiAliasingForGraphs; /** \brief specifies whether to use antialiasing when drawing any text * \note You can set this property \c false to increase plotting speed of complex plots (with many graphs inside). You can reach a * roughly three-fold speed improvement! */ bool useAntiAliasingForText; /** \brief default value for property property varname. \see useAntiAliasingForText for more information */ bool def_useAntiAliasingForText; /** \brief multiplier which is used for font sizes when the plot is exported/printed */ double fontSizePrintMultiplier; /** \brief multiplier which is used for linewidths when the plot is exported/printed */ double lineWidthPrintMultiplier; /** \brief multiplier for the font size */ double fontSizeMultiplier; /** \brief multiplier or the line widths */ double lineWidthMultiplier; /** \brief internal: used to store a list of all currently used plot styles */ QList usedStyles; /** \brief a vector that contains all graphs to be plottet in the system */ QList graphs; QList overlays; /** \brief used as maximum/minimum pixel value for plotting */ double plot_minmaxcoorinate; /** \brief hidden default constructor */ JKQtBasePlotter(); /** \brief paints the plot onto the given JKQTPEnhancedPainter object */ void paintPlot(JKQTPEnhancedPainter& painter, bool drawOverlays=true); void paintOverlays(JKQTPEnhancedPainter& painter); /** \brief simply calls paintPlot() if grid printing mode is deactivated and prints the graph grid otherwise * \a pageRect is used to determine the size of the page to draw on. If this does not coincide with * the widget extents this function calculates a scaling factor so the graphs fit onto the page. This * is especially usefull when printing! */ void gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool drawOverlays=true, bool scaleIfTooLarge=true, bool scaleIfTooSmall=true); void gridPaintOverlays(JKQTPEnhancedPainter& painter, QSizeF pageRect); /** \brief This method goes through all registered plotters and calculates the width of every column and * height of every row as the max over the row/column. The reults are stored in the private datamembers * gridPrintingRows and gridPrintingColumns. gridPrintingSize will contain the size of all graphs together * afterwards. */ void gridPrintingCalc(); /** \brief plot the grid */ virtual void plotSystemGrid(JKQTPEnhancedPainter& painter); /** \brief plot the x coordinate axis (incl. labels) */ virtual void plotSystemXAxis(JKQTPEnhancedPainter& painter); /** \brief plot the x coordinate axis (incl. labels) */ virtual void plotSystemYAxis(JKQTPEnhancedPainter& painter); /** \brief plot the graphs */ virtual void plotGraphs(JKQTPEnhancedPainter& painter); /** \brief plot a key */ virtual void plotKey(JKQTPEnhancedPainter& painter); /** \brief plot all overlay elements */ virtual void plotOverlays(JKQTPEnhancedPainter& painter); /** \brief plot the key contents * * This function does not do anything and has to be overwritten in child classes if they want to plot a key. * The implementation should draw the contents of the key, not its frame as this is done in plotKey(). * * \param painter draw the key on this painter * \param x left-most coordinate of the key [pixels] * \param y top-most coordinate of the key [pixels] * \param width width of the key [pixels] * \param height height of the key [pixels] * * So any implementation should only draw inside the rectangle [x..x+width, y..y+hieght] */ virtual void plotKeyContents(JKQTPEnhancedPainter& painter, double x, double y, double width, double height); /** \brief returns the size of the key (as call-by-reference parameters * * Any implementation of key plotting has to overwrite this function and use it to return the size of the key that would be * plotted by plotKeyContents(). This class will use the return values to plot the frame of the key and also supply them to * plotKeyContents(). If height or width are returned 0, no key is plotted * * The implementation in here returns zero size! */ virtual void getKeyExtent(JKQTPEnhancedPainter& painter, double *width, double *height, double *text_width=nullptr, double *text_height=nullptr, int *columns_count=nullptr, int* lines_count=nullptr); /** \brief QAction which triggers saving of the plot as an image */ QAction* actSavePlot; /** \brief QAction which triggers saving of the data used for the plot */ QAction* actSaveData; /** \brief QAction which triggers copying of the data to the clipboard */ QAction* actCopyData; /** \brief QAction which triggers copying of the image to the clipboard */ QAction* actCopyPixelImage; /** \brief QAction which triggers copying of the data to the clipboard in Matlab format */ QAction* actCopyMatlab; /** \brief QAction which triggers the saving as PDF */ QAction* actSavePDF; #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) /** \brief QAction which triggers the saving as PostScript */ QAction* actSavePS; #endif /** \brief QAction which triggers the saving as pixel image */ QAction* actSavePix; /** \brief QAction which triggers the saving as Scalable Vector Graphics (SVG) */ QAction* actSaveSVG; /** \brief QAction which triggers the printing */ QAction* actPrint; /** \brief QAction which triggers the saving as CSV (data only) */ QAction* actSaveCSV; /** \brief QAction which triggers zoom all */ QAction* actZoomAll; /** \brief QAction which triggers zoom in */ QAction* actZoomIn; /** \brief QAction which triggers zoom out */ QAction* actZoomOut; /** \brief QAction to show a table with all the plot data in the datastore */ QAction* actShowPlotData; /** \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! */ AdditionalActionsMap lstAdditionalPlotterActions; /** \brief the directory in which to open SaveAs ... dialogs */ QString currentSaveDirectory; QString currentFileFormat; QString currentDataFileFormat; QString currentPrinter; /** \brief the master plotter, this plotter is connected to. */ JKQtBasePlotter* masterPlotter; /** \brief synchronize plot width with masterPlotter */ bool masterSynchronizeWidth; /** \brief synchronize plot height with masterPlotter */ bool masterSynchronizeHeight; bool emitPlotSignals; void printpreview(QPrinter* p, bool setabsolutesize=false); bool printpreviewNew(QPaintDevice* paintDevice, bool setAbsolutePaperSize=false, double printsizeX_inMM=-1.0, double printsizeY_inMM=-1.0, bool displayPreview=true); bool exportpreview(QSizeF pageSize, bool unitIsMM=false); JKQTPSET_MACRO(double, fontSizeMultiplier) JKQTPSET_MACRO(double, lineWidthMultiplier) JKQTPGET_SET_MACRO(double, printMagnification) JKQTPGET_SET_MACRO(double, paintMagnification) QListWidget* dataColumnsListWidget; QComboBox* dataColumnsCombobox; QSet getDataColumnsByUser(); QMap getDataColumnsByUserSaved; private: double printZoomFactor; double printSizeX_Millimeter; double printSizeY_Millimeter; double printMagnification; QPointer printPreview; QPointer spinSizeX; QPointer spinSizeY; QPointer exportPreviewLabel; QPointer spinMagnification; bool printSetAbsolutePageSize; bool printSetAbsolutePlotSize; bool printKeepAbsoluteFontSizes; bool printScaleToPagesize; double printAspect; bool printKeepAspect; bool exportUnitInMM; QSizeF printPageSizeMM; bool printDoUpdate; protected slots: void updatePreviewLabel(); void printpreviewPaintRequested(QPrinter *printer); void printpreviewPaintRequestedNew(QPrinter *printer); void printpreviewPaintRequestedNew(QPaintDevice *paintDevice); void exportpreviewPaintRequested(JKQTPEnhancedPainter& painter, QSize size); void printpreviewSetZoom(double value); void printpreviewSetSizeX(double value); void printpreviewSetSizeY(double value); void printpreviewSetSizeXNew(double value); void printpreviewSetSizeYNew(double value); void printpreviewSetMagnification(double value); void printpreviewSetMagnificationNew(double value); void printpreviewSetAspectRatio(bool checked); void printpreviewSetKeepAbsFontsize(bool checked); void printpreviewToggleMagnification(bool checked); void printpreviewSetLineWidthMultiplier(double value); void printpreviewSetFontSizeMultiplier(double value); void printpreviewUpdate(); void getDataColumnsByUserCheckAll(); void getDataColumnsByUserCheckNone(); void getDataColumnsByUserSave(); void getDataColumnsByUserComboBoxSelected(const QString& name); void getDataColumnsByUserItemChanged(QListWidgetItem* widgetitem); void showPlotData(); /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis */ void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter* sender); /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local y-axis to the other y-axis */ void synchronizeYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter* sender); /** \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 */ void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter* sender); public slots: /** \brief sets x/ymin and x/ymax to the supplied values and replots the graph (zoom operation!) */ void zoom(double nxmin, double nxmax, double nymin, double nymax); /** \brief sets whether to plot grid lines or not */ void setGrid(bool val); /** \brief save the current plot as a pixel image image (PNG ...), if filename is empty a file selection dialog is displayed */ void saveAsPixelImage(QString filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray()); /** \brief copy the current plot as a pixel image to the clipboard */ void copyPixelImage(); /** \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 */ void saveAsSVG(QString filename=QString(""), bool displayPreview=true); /** \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 */ void saveAsPDF(QString filename=QString(""), bool displayPreview=true); /** \brief save the current plot as a PS file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */ void saveAsPS(QString filename=QString(""), bool displayPreview=true); /** \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. * The image format is extracted from the file extension (jpeg, tiff, png, pdf, ...) */ void saveImage(QString filename=QString(""), bool displayPreview=true); /** \brief save the data used for the current plot. The file format is extracted from the file extension (csv, ...) * * The parameter \a format specifies the export format. if it is empty the format will be choosen according to the file extension, or * if \a filename is also empty the format will be choosen according to what is selected in the file selection dialog. * * If \a format is \c "slk" the output will be in SYLK format, if \a format is \c "csv" or \a "dat" the output will be comma separated values * and if \a format is \c "txt" the output will be tab separated values. */ void saveData(QString filename=QString(""), QString jkqtp_format=QString("")); /** \brief copy the data used for the current plot to the clipboard * * copies data as tab separated data with the system-decimal point. */ void copyData(); /** \brief copy the data used for the current plot to the clipboard in Matlab format */ void copyDataMatlab(); /** \brief save the current plot data as a Comma Separated Values (CSV) file*/ virtual void saveAsCSV(QString filename=QString("")); /** \brief save the current plot data as a DIF file*/ virtual void saveAsDIF(QString filename=QString("")); /** \brief save the current plot data as a SYLK spreadsheet file*/ virtual void saveAsSYLK(QString filename=QString("")); /** \brief save the current plot data as a Matlab Script*/ virtual void saveAsMatlab(QString filename=QString("")); /** \brief save the current plot data as a Semicolon Separated Values (SSV) file*/ virtual void saveAsSemicolonSV(QString filename=QString("")); /** \brief save the current plot data as a Tabulator Separated Values (CSV) file*/ virtual void saveAsTabSV(QString filename=QString("")); /** \brief save the current plot data as a Semicolon Separated Values (CSV) file for german Excel, i.e. with comma as decimal separator*/ virtual void saveAsGerExcelCSV(QString filename=QString("")); /** \brief print the current plot, if printer is \c nullptr a printer selection dialog is displayed */ void print(QPrinter* printer=nullptr, bool displayPreview=true); /** \brief this method zooms the graph so that all plotted datapoints are visible. * * \param zoomX if set \c true (default) zooms the x axis * \param zoomY if set \c true (default) zooms the y axis * \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) * \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) * \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 * For logx plots we actually use this on the logarithmized data! (default: 1.05) * \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 * For log< plots we actually use this on the logarithmized data! (default: 1.05) * */ virtual void zoomToFit(bool zoomX=true, bool zoomY=true, bool includeX0=false, bool includeY0=false, double scaleX=1.05, double scaleY=1.05); /** \brief zooms into the graph (the same as turning the mouse wheel) by the given factor */ void zoomIn(double factor=2.0); /** \brief zooms out of the graph (the same as turning the mouse wheel) by the given factor */ void zoomOut(double factor=2.0) { zoomIn(1.0/factor); } /** \brief set the datarange of all current graphs to the given values */ void setGraphsDataRange(int datarange_start, int datarange_end); void set_maintainAspectRatio(bool value) { maintainAspectRatio=value; update_plot(); } void set_maintainAxisAspectRatio(bool value) { maintainAxisAspectRatio=value; update_plot(); } void set_userSettigsFilename(const QString& filename, const QString& prefix); void set_userSettigsFilename(const QString& filename); void set_userSettigsPrefix(const QString& prefix); QString get_userSettigsFilename() const; QString get_userSettigsPrefix() const; /** \brief set all graphs invisible, except i */ void setOnlyGraphVisible(int i); /** \brief set all graphs invisible, except graph start, start+n, start+2*n, ... */ void setOnlyNthGraphsVisible(int start, int n); /** \brief saves the plot user properties if userSettingsFilename is set, does nothing otherwise */ void loadUserSettings(); /** \brief saves the plot user properties if userSettingsFilename is set, does nothing otherwise */ void saveUserSettings(); public: /** \brief class constructor * * if \a datastore_internal is \c true then the constructor will create an internal datastore object. The datastore * will be managed (freed) by this class. If \a datastore_internal is \c false the class will use tha datastore provided * in \a datast as an external datastore. You can modify this later by using useInternalDatastore() and useExternalDatastore(). */ JKQtBasePlotter(bool datastore_internal, QObject* parent=nullptr, JKQTPdatastore* datast=nullptr); /** \brief class destructor */ virtual ~JKQtBasePlotter(); /** \brief returns a pointer to the datastore used by this object */ inline JKQTPdatastore* getDatastore() { return datastore; } /** \brief returns model representing all Plots in this plotter and showing their visible/invisible state */ inline JKQTPgraphsModel* getPlotsModel() { return m_plotsModel; } /** \brief returns a pointer to the datastore used by this object */ inline const JKQTPdatastore* getDatastore() const { return datastore; } /** \brief returns model representing all Plots in this plotter and showing their visible/invisible state */ inline const JKQTPgraphsModel* getPlotsModel() const { return m_plotsModel; } /** \brief tells the plotter object to use the given external datastore. * * If the current datastore is internally managed, this method will free that object and use the supplied datastore * with external management. If the current datastore is already external, this method will simply replace it by the * new one. */ void useExternalDatastore(JKQTPdatastore* newStore); /** \brief tells the plotter object to use the given external datastore and treat it as an internal one (i.e. free it * when the plotter object ist destroyed. */ void useAsInternalDatastore(JKQTPdatastore* newStore); /** \brief tells the plotter object to use an internal datastore. A new internal datastore object is generated only if * the current datastore is not internal. */ void useInternalDatastore(); /** \brief tells the plotter object to use an internal datastore (just like useInternalDatastore() ), but forces the * generation of a new datastore, even if the current one is already internal (the current one will be freed in * the lather case */ void forceInternalDatastore(); /** \brief returns the property emitSignals. \details Description of the parameter emitSignals is:
\copybrief emitSignals.
. \see emitSignals for more information */ inline bool get_emitSignals()const { return this->emitSignals; } void set_emitSignals(bool enabled); /** \brief loads the plot properties from a QSettings object */ virtual void loadSettings(QSettings& settings, QString group=QString("plots")); /** \brief saves the plot properties into a QSettings object. * * This method only saves those properties that differ from their default value. */ virtual void saveSettings(QSettings& settings, QString group=QString("plots")); /** \brief loads the plot user properties from a QSettings object */ virtual void loadUserSettings(QSettings& settings, QString group=QString("plots_user")); /** \brief saves the plot user properties into a QSettings object. */ virtual void saveUserSettings(QSettings& settings, QString group=QString("plots_user")); /** \brief sets the width of the plot widget */ void setWidth(int wid); /** \brief resize the plot */ void resize(int width, int height); /** \brief gets the width of the plot widget */ inline int getWidth() {return widgetWidth; } /** \brief gets the width of the plot widget */ inline int getHeight() {return widgetHeight; } /** \brief sets the width of the plot widget */ void setHeight(int heigh); /** \brief sets the borders of the plot, see also get_plotBorderTop(), plotBorderBottom(), plotBorderLeft(), plotBorderRight() */ void setBorder(int left, int right, int top, int bottom); /** \brief sets minimum and maximum x-value to plot */ void setX(double xminn, double xmaxx); /** \brief sets minimum and maximum y-value to plot */ void setY(double yminn, double ymaxx); /** \brief sets minimum and maximum x- and y-values to plot */ void setXY(double xminn, double xmaxx, double yminn, double ymaxx); /** \brief returns the current x-axis min */ inline double getXMin() const {return xAxis->getMin(); } /** \brief returns the current x-axis max */ inline double getXMax() const {return xAxis->getMax(); } /** \brief returns the current y-axis min */ inline double getYMin() const {return yAxis->getMin(); } /** \brief returns the current y-axis max */ inline double getYMax() const {return yAxis->getMax(); } /** \brief returns the given size in Didot points (0.376 mm) to pixels (with given dots per inch) */ inline double didot2px(double pt, double dpi) const { return dpi/25.4*0.376*pt; } /** \brief returns the given size in Didot points (0.376 mm) to pixels (with dpi from painter) */ inline double didot2px(double pt, JKQTPEnhancedPainter& painter) const { return didot2px(pt, painter.device()->logicalDpiX()); } /** \brief returns the given size in Didot points (0.376 mm) to pixels (with dpi from painter) */ inline double didot2px(JKQTPEnhancedPainter& painter, double pt) const { return didot2px(pt, painter.device()->logicalDpiX()); } /** \brief returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch) */ inline double pt2px(double pt, double dpi) const { return dpi*pt/72.0; } /** \brief returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch) */ inline double pt2px(double pt, JKQTPEnhancedPainter& painter) const { return pt2px(pt, painter.device()->logicalDpiX()); } /** \brief returns the given size in DTP points points (1/72inch = 0.353mm) to pixels (with given dots per inch) */ inline double pt2px(JKQTPEnhancedPainter& painter, double pt) const { return pt2px(pt, painter.device()->logicalDpiX()); } /** \brief returns the given size in millimeters to pixels (with given dots per inch) */ inline double mm2px(double mm, double dpi) const { return dpi*mm/25.4; } /** \brief returns the given size in millimeters to pixels (with given dots per inch) */ inline double mm2px(double mm, JKQTPEnhancedPainter& painter) const { return mm2px(mm, painter.device()->logicalDpiX()); } /** \brief returns the given size in millimeters to pixels (with given dots per inch) */ inline double mm2px(JKQTPEnhancedPainter& painter, double mm) const { return mm2px(mm, painter.device()->logicalDpiX()); } /** \brief sets absolute minimum and maximum x-value to plot * \note if the aspect ration of this does not fit into the widget, it is possible that you don't see the complete contents! */ void setAbsoluteX(double xminn, double xmaxx); /** \brief sets absolute minimum and maximum y-value to plot * \note if the aspect ration of this does not fit into the widget, it is possible that you don't see the complete contents! */ void setAbsoluteY(double yminn, double ymaxx); /** \brief sets absolute minimum and maximum x- and y-values to plot * \note if the aspect ration of this does not fit into the widget, it is possible that you don't see the complete contents! */ void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx); /** \brief returns the absolute x-axis min */ inline double getAbsoluteXMin() const {return xAxis->getAbsoluteMin(); } /** \brief returns the absolute x-axis max */ inline double getAbsoluteXMax() const {return xAxis->getAbsoluteMax(); } /** \brief returns the absolute y-axis min */ inline double getAbsoluteYMin() const {return yAxis->getAbsoluteMin(); } /** \brief returns the absolute y-axis max */ inline double getAbsoluteYMax() const {return yAxis->getAbsoluteMax(); } /** \brief add a new plotter for grid printing mode */ inline void addGridPrintingPlotter(size_t x, size_t y, JKQtBasePlotter* plotter) { JKQTPgridPrintingItem i; i.x=x; i.y=y; i.plotter=plotter; gridPrintingList.push_back(i); } /** \brief clear all additional plotters for grid printing mode */ inline void clearGridPrintingPlotters() { gridPrintingList.clear(); } /** \brief return x-pixel coordinate from time coordinate */ inline double x2p(double x) const { return xAxis->x2p(x); } /** \brief return y-pixel coordinate from y coordinate */ inline double y2p(double y) const { return yAxis->x2p(y); } /** \brief return time coordinate coordinate from x-pixel */ inline double p2x(long x) const { return xAxis->p2x(x); } /** \brief return y coordinate coordinate from y-pixel */ inline double p2y(long y) const { return yAxis->p2x(y); } /** \brief gets the next unused style id, i.e. the smalles number >=0 which is not contained in usedStyles */ int getNextStyle(); struct JKQTPPen { QColor m_color; double m_width; Qt::PenStyle m_style; void setWidthF(double w) { m_width=w; } void setWidth(double w) { m_width=w; } double width() const { return m_width; } double widthF() const { return m_width; } QColor color() const { return m_color; } void setColor(const QColor& col) {m_color=col; } Qt::PenStyle style() const { return m_style; } void setStyle(Qt::PenStyle s) { m_style=s; } }; /** \brief returns a QPen object for the i-th plot style */ JKQTPPen getPlotStyle(int i) const; /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ void draw(JKQTPEnhancedPainter& painter, QRect rect, bool drawOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ void drawOverlays(JKQTPEnhancedPainter& painter, QRect rect); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param pos where to plot the painter (left-top corner) */ void draw(JKQTPEnhancedPainter& painter, QPoint pos=QPoint(0,0), bool drawOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param rect rectangle to plot into */ void drawNonGrid(JKQTPEnhancedPainter& painter, QRect rect, bool drawOverlays=true); /*! \brief draw the contained graph (including grid prints) into the given JKQTPEnhancedPainter \param painter JKQTPEnhancedPainter to which the plot should be drawn \param pos where to plot the painter (left-top corner) */ void drawNonGrid(JKQTPEnhancedPainter& painter, QPoint pos=QPoint(0,0), bool drawOverlays=true); void drawNonGridOverlays(JKQTPEnhancedPainter &painter, QPoint pos=QPoint(0,0)); /** \brief emit plotUpdated() */ void update_plot() { if (emitPlotSignals) emit plotUpdated(); } JKQTPGET_SET_MACRO(bool, emitPlotSignals) /** \brief returns the property plotBorderTop. \details Description of the parameter plotBorderTop is:
\copybrief plotBorderTop.
. \see plotBorderTop for more information */ inline int get_plotBorderTop() const { return this->plotBorderTop; } /** \brief returns the property plotBorderLeft. \details Description of the parameter plotBorderLeft is:
\copybrief plotBorderLeft.
. \see plotBorderLeft for more information */ inline int get_plotBorderLeft() const { return this->plotBorderLeft; } /** \brief returns the property plotBorderBottom. \details Description of the parameter plotBorderBottom is:
\copybrief plotBorderBottom.
. \see plotBorderBottom for more information */ inline int get_plotBorderBottom() const { return this->plotBorderBottom; } /** \brief returns the property plotBorderRight. \details Description of the parameter plotBorderRight is:
\copybrief plotBorderRight.
. \see plotBorderRight for more information */ inline int get_plotBorderRight() const { return this->plotBorderRight; } /** \brief returns the property maintainAspectRatio. \details Description of the parameter maintainAspectRatio is:
\copybrief maintainAspectRatio.
. \see maintainAspectRatio for more information */ inline bool get_maintainAspectRatio() const { return this->maintainAspectRatio; } JKQTPGET_SET_MACRO_I(double, aspectRatio, update_plot()) /** \brief returns the property maintainAxisAspectRatio. \details Description of the parameter maintainAxisAspectRatio is:
\copybrief maintainAxisAspectRatio.
. \see maintainAxisAspectRatio for more information */ inline bool get_maintainAxisAspectRatio() const { return this->maintainAxisAspectRatio; } JKQTPGET_SET_MACRO_I(double, axisAspectRatio, update_plot()) JKQTPGET_SET_MACRO_I(bool, useAntiAliasingForSystem, update_plot()) JKQTPGET_SET_MACRO_I(bool, useAntiAliasingForGraphs, update_plot()) JKQTPGET_SET_MACRO_I(bool, useAntiAliasingForText, update_plot()) JKQTPGET_SET_MACRO_I(QColor, graphColor, update_plot()) JKQTPGET_SET_MACRO_I(double, graphWidth, update_plot()) JKQTPGET_SET_MACRO_I(QColor, backgroundColor, update_plot()) JKQTPGET_SET_MACRO_I(QColor, exportBackgroundColor, update_plot()) JKQTPGET_SET_MACRO_I(QColor, plotBackgroundColor, update_plot()) JKQTPGET_SET_MACRO_I(QString, keyFont, update_plot()) JKQTPGET_SET_MACRO_I(double, keyFontSize, update_plot()) JKQTPGET_SET_MACRO_I(double, key_item_width, update_plot()) JKQTPGET_SET_MACRO_I(double, key_item_height, update_plot()) JKQTPGET_SET_MACRO_I(double, keyYSeparation, update_plot()) JKQTPGET_SET_MACRO_I(double, key_line_length, update_plot()) JKQTPGET_SET_MACRO_I(double, keyXMargin, update_plot()) JKQTPGET_SET_MACRO_I(double, keyYMargin, update_plot()) JKQTPGET_SET_MACRO_I(double, keyXSeparation, update_plot()) JKQTPGET_SET_MACRO_I(double, keyXOffset, update_plot()) JKQTPGET_SET_MACRO_I(double, keyYOffset, update_plot()) JKQTPGET_SET_MACRO_I(bool, showKey, update_plot()) JKQTPGET_SET_MACRO_I(bool, showKeyFrame, update_plot()) JKQTPGET_SET_MACRO_I(QColor, keyFrameColor, update_plot()) JKQTPGET_SET_MACRO_I(QColor, keyBackgroundColor, update_plot()) JKQTPGET_SET_MACRO_I(double, keyFrameWidth, update_plot()) JKQTPGET_SET_MACRO_I(bool, keyAutosize, update_plot()) JKQTPGET_SET_MACRO_I(JKQTPkeyPosition, keyPosition, update_plot()) JKQTPGET_SET_MACRO_I(JKQTPkeyLayout, keyLayout, update_plot()) JKQTPGET_SET_MACRO_I(double, plotLabelFontSize, update_plot()) JKQTPGET_SET_MACRO_I(QString, plotLabelFontname, update_plot()) JKQTPGET_SET_MACRO_I(QString, plotLabel, update_plot()) JKQTPGET_SET_MACRO(bool, gridPrinting) JKQTPGET_SET_MACRO(size_t, gridPrintingCurrentX) JKQTPGET_SET_MACRO(size_t, gridPrintingCurrentY) JKQTPGET_SET_MACRO(QString, currentSaveDirectory) JKQTPGET_SET_MACRO(QString, currentFileFormat) JKQTPGET_SET_MACRO(QString, CSVdecimalSeparator) JKQTPGET_SET_MACRO(QString, CSVcommentInitializer) /** \brief returns the property iplotBorderTop. \details Description of the parameter iplotBorderTop is:
\copybrief iplotBorderTop.
. \see iplotBorderTop for more information */ inline int get_iplotBorderTop() const { return this->iplotBorderTop; } /** \brief returns the property iplotBorderLeft. \details Description of the parameter iplotBorderLeft is:
\copybrief iplotBorderLeft.
. \see iplotBorderLeft for more information */ inline int get_iplotBorderLeft() const { return this->iplotBorderLeft; } /** \brief returns the property iplotBorderBottom. \details Description of the parameter iplotBorderBottom is:
\copybrief iplotBorderBottom.
. \see iplotBorderBottom for more information */ inline int get_iplotBorderBottom() const { return this->iplotBorderBottom; } /** \brief returns the property iplotBorderRight. \details Description of the parameter iplotBorderRight is:
\copybrief iplotBorderRight.
. \see iplotBorderRight for more information */ inline int get_iplotBorderRight() const { return this->iplotBorderRight; } /** \brief returns the property plotWidth. \details Description of the parameter plotWidth is:
\copybrief plotWidth.
. \see plotWidth for more information */ inline int get_plotWidth() const { return this->plotWidth; } /** \brief returns the property plotHeight. \details Description of the parameter plotHeight is:
\copybrief plotHeight.
. \see plotHeight for more information */ inline int get_plotHeight() const { return this->plotHeight; } inline JKQTmathText* get_mathText() { return &mathText; } inline const JKQTmathText* get_mathText() const { return &mathText; } inline JKQTPhorizontalAxis* get_xAxis() { return xAxis; } inline JKQTPverticalAxis* get_yAxis() { return yAxis; } inline const JKQTPhorizontalAxis* get_xAxis() const { return xAxis; } inline const JKQTPverticalAxis* get_yAxis() const { return yAxis; } /** \brief returns the property actSavePlot. \details Description of the parameter actSavePlot is:
\copybrief actSavePlot.
. \see actSavePlot for more information */ inline QAction* get_actSavePlot() const { return this->actSavePlot; } /** \brief returns the property actSaveData. \details Description of the parameter actSaveData is:
\copybrief actSaveData.
. \see actSaveData for more information */ inline QAction* get_actSaveData() const { return this->actSaveData; } /** \brief returns the property actCopyData. \details Description of the parameter actCopyData is:
\copybrief actCopyData.
. \see actCopyData for more information */ inline QAction* get_actCopyData() const { return this->actCopyData; } /** \brief returns the property actCopyPixelImage. \details Description of the parameter actCopyPixelImage is:
\copybrief actCopyPixelImage.
. \see actCopyPixelImage for more information */ inline QAction* get_actCopyPixelImage() const { return this->actCopyPixelImage; } /** \brief returns the property actCopyMatlab. \details Description of the parameter actCopyMatlab is:
\copybrief actCopyMatlab.
. \see actCopyMatlab for more information */ inline QAction* get_actCopyMatlab() const { return this->actCopyMatlab; } /** \brief returns the property actSavePDF. \details Description of the parameter actSavePDF is:
\copybrief actSavePDF.
. \see actSavePDF for more information */ inline QAction* get_actSavePDF() const { return this->actSavePDF; } #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) /** \brief returns the property actSavePS. \details Description of the parameter actSavePS is:
\copybrief actSavePS.
. \see actSavePS for more information */ inline QAction* get_actSavePS() const { return this->actSavePS; } #endif /** \brief returns the property actSavePix. \details Description of the parameter actSavePix is:
\copybrief actSavePix.
. \see actSavePix for more information */ inline QAction* get_actSavePix() const { return this->actSavePix; } /** \brief returns the property actSaveSVG. \details Description of the parameter actSaveSVG is:
\copybrief actSaveSVG.
. \see actSaveSVG for more information */ inline QAction* get_actSaveSVG() const { return this->actSaveSVG; } /** \brief returns the property actPrint. \details Description of the parameter actPrint is:
\copybrief actPrint.
. \see actPrint for more information */ inline QAction* get_actPrint() const { return this->actPrint; } /** \brief returns the property actSaveCSV. \details Description of the parameter actSaveCSV is:
\copybrief actSaveCSV.
. \see actSaveCSV for more information */ inline QAction* get_actSaveCSV() const { return this->actSaveCSV; } /** \brief returns the property actZoomAll. \details Description of the parameter actZoomAll is:
\copybrief actZoomAll.
. \see actZoomAll for more information */ inline QAction* get_actZoomAll() const { return this->actZoomAll; } /** \brief returns the property actZoomIn. \details Description of the parameter actZoomIn is:
\copybrief actZoomIn.
. \see actZoomIn for more information */ inline QAction* get_actZoomIn() const { return this->actZoomIn; } /** \brief returns the property actZoomOut. \details Description of the parameter actZoomOut is:
\copybrief actZoomOut.
. \see actZoomOut for more information */ inline QAction* get_actZoomOut() const { return this->actZoomOut; } /** \brief returns the property actShowPlotData. \details Description of the parameter actShowPlotData is:
\copybrief actShowPlotData.
. \see actShowPlotData for more information */ inline QAction* get_actShowPlotData() const { return this->actShowPlotData; } /** \brief returns the property lstAdditionalPlotterActions. \details Description of the parameter lstAdditionalPlotterActions is:
\copybrief lstAdditionalPlotterActions.
. \see lstAdditionalPlotterActions for more information */ inline AdditionalActionsMap get_lstAdditionalPlotterActions() const { return this->lstAdditionalPlotterActions; } /** \brief this function registers additional actions to lstAdditionalPlotterActions, which are displayed in the context-menu */ void registerAdditionalAction(const QString& key, QAction* act); void deregisterAdditionalAction(QAction* act); /** \brief returns the property masterSynchronizeWidth. \details Description of the parameter masterSynchronizeWidth is:
\copybrief masterSynchronizeWidth.
. \see masterSynchronizeWidth for more information */ inline bool get_masterSynchronizeWidth() const { return this->masterSynchronizeWidth; } /** \brief returns the property masterSynchronizeHeight. \details Description of the parameter masterSynchronizeHeight is:
\copybrief masterSynchronizeHeight.
. \see masterSynchronizeHeight for more information */ inline bool get_masterSynchronizeHeight() const { return this->masterSynchronizeHeight; } JKQTPSET_MACRO(QColor, def_backgroundColor) JKQTPSET_MACRO(QColor, def_plotBackgroundColor) JKQTPGET_SET_MACRO(double, fontSizePrintMultiplier) JKQTPGET_SET_MACRO(double, lineWidthPrintMultiplier) /** \brief returns the property fontSizeMultiplier. \details Description of the parameter fontSizeMultiplier is:
\copybrief fontSizeMultiplier.
. \see fontSizeMultiplier for more information */ inline double get_fontSizeMultiplier() const { return this->fontSizeMultiplier; } /** \brief returns the property lineWidthMultiplier. \details Description of the parameter lineWidthMultiplier is:
\copybrief lineWidthMultiplier.
. \see lineWidthMultiplier for more information */ inline double get_lineWidthMultiplier() const { return this->lineWidthMultiplier; } /** \brief returns description of i'th graph */ JKQTPplotElement* getGraph(size_t i); /** \brief returns the number of graphs */ size_t getGraphCount(); /** \brief remove the i-th graph */ void deleteGraph(size_t i, bool deletegraph=true); /** \brief remove the given graph, if it is contained */ void deleteGraph(JKQTPplotElement* gr, bool deletegraph=true); /** \brief remove all plots * * \param deleteGraphs if set \c true (default) the graph objects will also be deleted */ void clearGraphs(bool deleteGraphs=true); void setAllGraphsInvisible(); void setAllGraphsVisible(); void setGraphVisible(int i, bool visible=true); /** \brief add a new graph, returns it's position in the graphs list, if the graph is already in the plot, this returns the index in the list */ size_t addGraph(JKQTPplotElement* gr); /** \brief returns \c true, if the given graph is in this plot */ bool containsGraph(JKQTPplotElement* gr) const; /** \brief move the given graph to the top, or add it, if it is not yet contained */ size_t moveGraphTop(JKQTPplotElement* gr); /** \brief move the given graph to the top, or add it, if it is not yet contained */ size_t moveGraphBottom(JKQTPplotElement* gr); /** \brief add a new graphs from a QVector */ template inline void addGraphs(const TJKQTPgraphContainer& gr) { for (auto it=gr.begin(); it!=gr.end(); ++it) { addGraph(*it); } } /** \brief add a new graph, returns it's position in the graphs list. * * \param xColumn the column which contains the x-values of the datapoints * \param yColumn the column which contains the y-values of the datapoints * \param title a title for this specific graph which can be displayed in the key * \param graphStyle the way how to plot the graph * * Both point to columns in the datastore explained in the JKQtPlotterBase class. The plotWidth, color, pen style ... * will be extracted from the automatic plot style creation mechanism implemented in JKQtPlotterBase::getNextStyle(). * If you want to change them either use another overloaded version of addGraph(), or use getGraph() and setGraph(): * \code * size_t i=addGraph(0,1,"graph1"); * JKQTPplotElement gr=getGraph(i); * gr.color=QColor("red"); * setGraph(i, gr); * \endcode */ size_t addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPgraphPlotstyle graphStyle=JKQTPlines); /** \brief add a new graph, returns it's position in the graphs list. * * \param xColumn the column which contains the x-values of the datapoints * \param yColumn the column which contains the y-values of the datapoints * \param title a title for this specific graph which can be displayed in the key * \param graphStyle the way how to plot the graph * \param symbol a symbol to use for the datapoints in some plot styles * \param color the color of the graph * \param width width (in pixel) of the graph * \param penstyle the drawing style (solid, dashed ...) of the graph lines. * * Both point to columns in the datastore explained in the JKQtPlotterBase class. * The symbolSize is set to 10 and no error information is expected. */ size_t addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPgraphPlotstyle graphStyle, QColor color, JKQTPgraphSymbols symbol=JKQTPcross, Qt::PenStyle penstyle=Qt::SolidLine, double width=2); /** \brief add a new graph with x-error information, returns it's position in the graphs list. * * * \param xColumn the column which contains the x-values of the datapoints * \param yColumn the column which contains the y-values of the datapoints * \param xErrorColumn the column which contains the x-value errors of the datapoints * \param title a title for this specific graph which can be displayed in the key * \param graphStyle the way how to plot the graph * \param errorStyle the drawing style (bars, lines ...) of the errors. * * Both point to columns in the datastore explained in the JKQtPlotterBase class. * The symbolSize is set to 10 and no error information is expected. */ size_t addGraphWithXError(size_t xColumn, size_t yColumn, size_t xErrorColumn, QString title, JKQTPgraphPlotstyle graphStyle=JKQTPpoints, JKQTPerrorPlotstyle errorStyle=JKQTPerrorBars); /** \brief add a new graph with x-error information, returns it's position in the graphs list. * * * \param xColumn the column which contains the x-values of the datapoints * \param yColumn the column which contains the y-values of the datapoints * \param yErrorColumn the column which contains the y-value errors of the datapoints * \param title a title for this specific graph which can be displayed in the key * \param graphStyle the way how to plot the graph * \param errorStyle the drawing style (bars, lines ...) of the errors. * * Both point to columns in the datastore explained in the JKQtPlotterBase class. * The symbolSize is set to 10 and no error information is expected. */ size_t addGraphWithYError(size_t xColumn, size_t yColumn, size_t yErrorColumn, QString title, JKQTPgraphPlotstyle graphStyle=JKQTPpoints, JKQTPerrorPlotstyle errorStyle=JKQTPerrorBars); /** \brief add a new graph with x-error information, returns it's position in the graphs list. * * * \param xColumn the column which contains the x-values of the datapoints * \param yColumn the column which contains the y-values of the datapoints * \param xErrorColumn the column which contains the x-value errors of the datapoints * \param yErrorColumn the column which contains the y-value errors of the datapoints * \param title a title for this specific graph which can be displayed in the key * \param graphStyle the way how to plot the graph * * Both point to columns in the datastore explained in the JKQtPlotterBase class. * The symbolSize is set to 10 and no error information is expected. The errorStyle is set to JKQTPerrorBars * for both directions. */ size_t addGraphWithXYError(size_t xColumn, size_t yColumn, size_t xErrorColumn, size_t yErrorColumn, QString title, JKQTPgraphPlotstyle graphStyle=JKQTPpoints); /** \brief add a boxplot graph to the plot * * \param title title of the plot * \param posColumn column containing the positions * \param medianColumn column containing the median values * \param minColumn column containing the minimum values * \param maxColumn column containing the maximum values * \param percentile25Column column containing the 25% percentiles * \param percentile75Column column containing the 75% percentiles * \param meanColumn column containing the mean value (this column is optional. If you don't want a mean symbol, set this to -1 */ size_t addHorizontalBoxplot(QString title, int posColumn, int medianColumn, int minColumn, int maxColumn, int percentile25Column, int percentile75Column, int meanColumn=-1); /** \brief add a boxplot graph to the plot * * \param title title of the plot * \param posColumn column containing the positions * \param medianColumn column containing the median values * \param minColumn column containing the minimum values * \param maxColumn column containing the maximum values * \param percentile25Column column containing the 25% percentiles * \param percentile75Column column containing the 75% percentiles * \param meanColumn column containing the mean value (this column is optional. If you don't want a mean symbol, set this to -1 */ size_t addVerticalBoxplot(QString title, int posColumn, int medianColumn, int minColumn, int maxColumn, int percentile25Column, int percentile75Column, int meanColumn=-1); /** \brief add one bargraph for each of the given set of \f$ f(x) \f$ -values which all use one column of x-values * * \param xColumn column with the x-values, which are common to all bargraphs * \param yColumns columns for the y-values * \param titles titles of the plot * * Here is an example output: * \image html plot_bargraphhorplot.png */ void addHorizontalBargraph(size_t xColumn, QVector yColumns, QStringList titles); /** \brief add a bargraph for the given set of \f$ f(x) \f$ -values for one column of x-values * * \param xColumns columns with the x-values * \param yColumn column for the y-values, which are common to all bargraphs * \param titles titles of the plot * * Here is an example output: * \image html plot_bargraphhorplot.png */ void addVerticalBargraph(QVector xColumns, size_t yColumn, QStringList titles); /** \brief get the maximum and minimum x-value over all graphs in the plot * \param[out] minx smallest x value * \param[out] maxx largest x value * \param[out] smallestGreaterZero smallest data point which is >0 (needed for scaling of logarithmic axes) * * The result is given in the two parameters which are call-by-reference parameters! */ void getGraphsXMinMax(double& minx, double& maxx, double& smallestGreaterZero); /** \brief get the maximum and minimum y-value over all graphs in the plot * \param[out] miny smallest y value * \param[out] maxy largest y value * \param[out] smallestGreaterZero smallest data point which is >0 (needed for scaling of logarithmic axes) * * The result is given in the two parameters which are call-by-reference parameters! */ void getGraphsYMinMax(double& miny, double& maxy, double& smallestGreaterZero); /*! \brief synchronize the plot borders with a given plotter This function allows two plotters to draw a graph with exactly the same height or width as in another graph. For example if you want to have two plotters which are positioned one above the other (and have the same widget widths, which could be guaranteed by a QLayout) you may want to make sure that their plotWidth s are always the same. In this case call \code plotter2->synchronizeToMaster(plotter1, true, false) \endcode of the lower plotter \c plotter2 . Now whenever the size of plotter1 changes, also plotter2 is redrawn with the changed borders. \param master the plotter widget to synchronize to \param synchronizeWidth do you want the plot width to be synchronized? \param synchronizeHeight do you want the plot height to be synchronized? \param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave \param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master */ void synchronizeToMaster(JKQtBasePlotter* master, bool synchronizeWidth, bool synchronizeHeight, bool synchronizeZoomingMasterToSlave=false, bool synchronizeZoomingSlaveToMaster=false); /** \brief switches any synchronization off, that has been created by synchronizeToMaster() */ void resetMasterSynchronization(); /** \brief returns description of i'th overlay element */ JKQTPoverlayElement* getOverlayElement(size_t i); /** \brief returns the number of overlay elements */ size_t getOverlayElementCount(); /** \brief remove the i-th overlay element */ void deleteOverlayElement(size_t i, bool deletegraph=true); /** \brief remove the given overlay element, if it is contained */ void deleteOverlayElement(JKQTPoverlayElement* gr, bool deletegraph=true); /** \brief remove all overlay elements * * \param deleteGraphs if set \c true (default) the overlay element objects will also be deleted */ void clearOverlayElement(bool deleteGraphs=true); /** \brief add a new overlay element, returns it's position in the overlay elements list, if the overlay element is already in the plot, this returns the index in the list */ size_t addOverlayElement(JKQTPoverlayElement* gr); /** \brief returns \c true, if the given overlay element is in this plot */ bool containsOverlayElement(JKQTPoverlayElement* gr) const; /** \brief move the given overlay element to the top, or add it, if it is not yet contained */ size_t moveOverlayElementTop(JKQTPoverlayElement* gr); /** \brief add a new overlay elements from a QList */ void addOverlayElements(const QList& gr); QVector getBoundingLinesX1Y1(QRectF *rect=nullptr) const; signals: /** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse) */ void zoomChangedLocally(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter* sender); /** \brief emitted when the plot has to be updated */ void plotUpdated(); /** \brief emitted when the overlay elements have to be updated */ void overlaysUpdated(); /** \brief emitted when the plot scaling had to be recalculated */ void plotScalingRecalculated(); /** \brief emitted before the plot scaling has been recalculated */ void beforePlotScalingRecalculate(); public: /** \brief set a global preset/default value for the userSettigsFilename and userSettigsPrefix properties of JKQtBasePlotter * \ingroup jkqtplotter * * These presets are application global and will be used ONLY on initialization of a JKQtBasePlotter. You can overwrite them * on a local-basis for each JKQtBasePrinter separately. The changed values from this function call will only take effect for * newly created plotters AFTER the function call! */ static void setDefaultJKQtBasePrinterUserSettings(QString userSettigsFilename, QString userSettigsPrefix); class LIB_EXPORT JKQTPPaintDeviceAdapter { public: virtual ~JKQTPPaintDeviceAdapter() {} virtual QString getFilter() const=0; virtual QString getFormatName() const=0; virtual QString getFormatID() const=0; virtual QStringList getFileExtension() const=0; virtual bool getSetAbsolutePaperSize() const=0; virtual double getPrintSizeXInMM() const =0; virtual double getPrintSizeYInMM() const =0; virtual bool isPrinter() const=0; virtual bool useLatexParser() const; /** \brief create a paint device with a given size in pixels */ virtual QPaintDevice* createPaintdevice(const QString& filename, int widthPix, int heightPix) const=0; /** \brief create a paint device with a given size in millimeters ... the default implementation call createPaintdevice(), assuming the standard logical resolution of the desktop!!!) */ virtual QPaintDevice* createPaintdeviceMM(const QString& filename, double widthMM, double heightMM) const; }; static void registerPaintDeviceAdapter(JKQTPPaintDeviceAdapter* adapter); static void deregisterPaintDeviceAdapter(JKQTPPaintDeviceAdapter* adapter); class LIB_EXPORT JKQTPSaveDataAdapter { public: virtual ~JKQTPSaveDataAdapter() ; virtual QString getFilter() const=0; virtual void saveJKQTPData(const QString& filename, const QList >& data, const QStringList& columnNames) const=0; }; static bool registerSaveDataAdapter(JKQTPSaveDataAdapter* adapter); static bool deregisterSaveDataAdapter(JKQTPSaveDataAdapter* adapter); struct LIB_EXPORT textSizeData { explicit textSizeData(); double ascent, descent, width, strikeoutPos; }; struct LIB_EXPORT textSizeKey { explicit textSizeKey(const QFont& f, const QString& text, QPaintDevice *pd); explicit textSizeKey(const QString& fontName, double fontSize, const QString& text, QPaintDevice *pd); QString text; QFont f; int ldpiX, ldpiY, pdpiX, pdpiY; bool operator==(const textSizeKey& other) const; }; textSizeData getTextSizeDetail(const QFont &fm, const QString& text, QPainter& painter); textSizeData getTextSizeDetail(const QString& fontName, double fontSize, const QString& text, QPainter &painter); void getTextSizeDetail(const QString& fontName, double fontSize, const QString& text, QPainter &painter, double& width, double& ascent, double& descent, double& strikeoutPos); void getTextSizeDetail(const QFont& fm, const QString& text, QPainter &painter, double& width, double& ascent, double& descent, double& strikeoutPos); QSizeF getTextSizeSize(const QFont &fm, const QString& text, QPainter& painter); QSizeF getTextSizeSize(const QString& fontName, double fontSize, const QString& text, QPainter &painter); protected: static QHash tbrh; }; inline uint qHash(const JKQtBasePlotter::textSizeKey& data) { return qHash(data.f.family())+qHash(data.text); } #endif // JKQTPBASEPLOTTER_H