diff --git a/examples/jkqtplot_test/TestWidgetContourPlots.cpp b/examples/jkqtplot_test/TestWidgetContourPlots.cpp index a1700af08a..d69daeba3b 100644 --- a/examples/jkqtplot_test/TestWidgetContourPlots.cpp +++ b/examples/jkqtplot_test/TestWidgetContourPlots.cpp @@ -88,7 +88,7 @@ TestWidgetContourPlots::TestWidgetContourPlots(QWidget *parent) : densityplot->setTitle("density plot"); plotContour->addGraph(densityplot); plotContour->setGrid(false); - plotDensity->zoom(-0.1,1.1,-0.1,1.1); + plotDensity->setXY(-0.1,1.1,-0.1,1.1); QVector levels; // levels<<5<<10<<25; // levels<<5.1<<10.1; @@ -105,7 +105,7 @@ TestWidgetContourPlots::TestWidgetContourPlots(QWidget *parent) : cp->setContourLevels(levels); cp->setTitle("contour plot"); plotContour->addGraph(cp); - plotContour->zoom(-0.1,1.1,-0.1,1.1); + plotContour->setXY(-0.1,1.1,-0.1,1.1); plotContour->setPlotUpdateEnabled(true); plotContour->redrawPlot(); diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp index 0c16f15dd7..4117b28b2b 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.cpp +++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp @@ -488,18 +488,6 @@ void JKQTBasePlotter::setMaintainAxisAspectRatio(bool value) { redrawPlot(); } -void JKQTBasePlotter::zoom(double nxmin, double nxmax, double nymin, double nymax){ - // only react on double clicks inside event - double xmin=nxmin; - double xmax=nxmax; - double ymin=nymin; - double ymax=nymax; - - xAxis->setRange(xmin, xmax); - yAxis->setRange(ymin, ymax); - redrawPlot(); - if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this); -} void JKQTBasePlotter::setWidgetSize(int wid, int heigh) { widgetWidth=wid; diff --git a/lib/jkqtplotter/jkqtpbaseplotter.h b/lib/jkqtplotter/jkqtpbaseplotter.h index f6e0d0789b..960974751c 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.h +++ b/lib/jkqtplotter/jkqtpbaseplotter.h @@ -1642,35 +1642,50 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject { * Uppon setting, this function emits the signal zoomChangedLocally(), if emitting signals * is activated at the moment (e.g. using setEmittingSignalsEnabled() ). * - * \see setX(), setX(), zoomToFit(), setAbsoluteXY(), JKQTPlotter::setXY() + * \see setX(), setX(), zoomToFit(), setAbsoluteXY() */ void setXY(double xminn, double xmaxx, double yminn, double ymaxx, bool affectsSecondaryAxes=false); + + /** \copydoc setXY() + * \deprecated The function JKQTBasePlotter::zoom() is deprecated and will be removed in future version, use JKQTBasePlotter::setXY() instead! + */ + inline void zoom(double xminn, double xmaxx, double yminn, double ymaxx, bool affectsSecondaryAxes=false) { + setXY(xminn, xmaxx, yminn, ymaxx, affectsSecondaryAxes); + } + /** \brief sets absolutely limiting x-range of the plot + * + * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function. + * This is implemented by calling JKQTPCoordinateAxis::setAbsoluteRange() for the major x-axes! * * \param xminn absolute minimum of x-axis * \param xmaxx absolute maximum of x-axis * * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! * - * \see setAbsoluteXY(), setAbsoluteY(), JKQTPlotter::setAbsoluteX() + * \see setAbsoluteXY(), setAbsoluteY(), JKQTPCoordinateAxis::setAbsoluteRange() */ void setAbsoluteX(double xminn, double xmaxx); /** \brief sets absolute minimum and maximum y-value to plot + * + * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function. + * This is implemented by calling JKQTPCoordinateAxis::setAbsoluteRange() for the major y-axes! * * \param yminn absolute minimum of y-axis * \param ymaxx absolute maximum of y-axis * * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! * - * \see setAbsoluteXY(), setAbsoluteX(), JKQTPlotter::setAbsoluteY() + * \see setAbsoluteXY(), setAbsoluteX(), JKQTPCoordinateAxis::setAbsoluteRange() */ void setAbsoluteY(double yminn, double ymaxx); /** \brief sets absolutely limiting x- and y-range of the plot * * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function. + * This is implemented by calling JKQTPCoordinateAxis::setAbsoluteRange() for the major axes! * * \param xminn absolute minimum of x-axis * \param xmaxx absolute maximum of x-axis @@ -1679,55 +1694,71 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject { * * \note if the aspect ratio of this does not fit into the widget, it is possible that you don't see the complete contents! * - * \see setAbsoluteX(), setAbsoluteY(), zoomToFit(), JKQTPlotter::setAbsoluteXY() + * \see setAbsoluteX(), setAbsoluteY(), JKQTPCoordinateAxis::setAbsoluteRange() */ void setAbsoluteXY(double xminn, double xmaxx, double yminn, double ymaxx); - /** \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 + /** \brief sets whether the major grid lines of the major axes are shown * * \image html jkqtplotter_gridvisible.png "Grid visible" * \image html jkqtplotter_gridinvisible.png "Grid invisible" + * + * \see JKQTPCoordinateAxis::setDrawGrid() and JKQTPGridStyle::enabled in JKQTPCoordinateAxisStyle::majorGridStyle */ void setGrid(bool val); - /** \brief sets the color of all Major grid lines + /** \brief sets the color of all major grid lines (of the major x- and y-axis) + * + * \see JKQTPCoordinateAxis::setGridColor() and JKQTPGridStyle::lineColor in JKQTPCoordinateAxisStyle::majorGridStyle * */ void setGridColor(QColor color); - /** \brief sets the color of all minor grid lines + /** \brief sets the color of all minor grid lines (of the major x- and y-axis) + * + * \see JKQTPCoordinateAxis::setMinorGridColor() and JKQTPGridStyle::lineColor in JKQTPCoordinateAxisStyle::minorGridStyle * */ void setMinorGridColor(QColor color); /** \brief sets the width of all Major grid lines + * + * \see JKQTPCoordinateAxis::setGridWidth() and JKQTPGridStyle::lineWidth in JKQTPCoordinateAxisStyle::majorGridStyle * */ void setGridWidth(double __value); /** \brief sets the width of all minor grid lines - * */ + * + * \see JKQTPCoordinateAxis::setMinorGridWidth() and JKQTPGridStyle::lineWidth in JKQTPCoordinateAxisStyle::minorGridStyle + */ void setMinorGridWidth(double __value); /** \brief sets the style of all Major grid lines + * + * \see JKQTPCoordinateAxis::setGridStyle() and JKQTPGridStyle::lineStyle in JKQTPCoordinateAxisStyle::majorGridStyle * */ void setGridStyle(Qt::PenStyle __value); /** \brief sets the style of all minor grid lines + * + * \see JKQTPCoordinateAxis::setMinorGridStyle() and JKQTPGridStyle::lineStyle in JKQTPCoordinateAxisStyle::minorGridStyle * */ void setMinorGridStyle(Qt::PenStyle __value); - /** \brief switches the visibility of the zero-axes associated with the x- and y-axis + /** \brief switches the visibility of the zero-axes associated with the major x- and y-axis * * \param showX indicates whether to show the zero-axis associated with the x-axis (i.e. x==0 or the vertical zero-axis) * \param showY indicates whether to show the zero-axis associated with the y-axis (i.e. y==0 or the horizontal zero-axis) + * + * \see JKQTPCoordinateAxis::showZeroAxis() and JKQTPCoordinateAxisStyle::showZeroAxis * */ void setShowZeroAxes(bool showX, bool showY); - /** \brief switches the visibility of the zero-axes associated with the x- and y-axis + /** \brief switches the visibility of the zero-axes associated with the major x- and y-axis * - * \param showXY indicates whether to show the zero-axis associated with the x- and y-axis + * \param showXY indicates whether to show the zero-axis associated with the x- y-axis + * + * \see JKQTPCoordinateAxis::showZeroAxis() and JKQTPCoordinateAxisStyle::showZeroAxis * */ void setShowZeroAxes(bool showXY); @@ -1738,10 +1769,18 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject { * \param outputFormmat specify the file format for the generated file * \param outputSizeIncrease if given, the size of the generated pixel image is increased by this number of pixels in addition to the required space * \return returns \c true on success + * + * This function may generate any pixel-graphics format, supported by Qt and listed in QImageWriter::supportedImageFormats(). + * The parameters are comparable to the standard Qt functions like QImage::save(), which is also used internally. + * + * \see grabPixelImage(), copyPixelImage() */ bool saveAsPixelImage(const QString& filename=QString(""), bool displayPreview=true, const QByteArray &outputFormat=QByteArray(), const QSize& outputSizeIncrease=QSize(0,0)); - /** \brief save the current plot as a pixel image into a QImage with the given size */ + /** \brief returns a rendering of the current plot as a QImage (pixel image) with the given size + * + * \see saveAsPixelImage(), copyPixelImage() + */ QImage grabPixelImage(QSize size=QSize(), bool showPreview=false); /** \brief copy the current plot as a pixel+svg image to the clipboard */ void copyPixelImage(bool showPreview=true); @@ -1774,6 +1813,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject { * \param filename the filename to save to, if empty a file save dialog is displayed * \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. * \return Returns \c true if the file was save successfully + * + * 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). + * Also it may use the custom exporters implemented as JKQTPPaintDeviceAdapter and registered via JKQTBasePlotter::registerPaintDeviceAdapter(). + * + * \see grabPixelImage(), copyPixelImage(), saveAsPixelImage(), JKQTBasePlotter::registerPaintDeviceAdapter(), JKQTPPaintDeviceAdapter */ bool saveImage(const QString& filename=QString(""), bool displayPreview=true); diff --git a/lib/jkqtplotter/jkqtpcoordinateaxes.h b/lib/jkqtplotter/jkqtpcoordinateaxes.h index 1029ce54f1..8fbd3a6fe0 100644 --- a/lib/jkqtplotter/jkqtpcoordinateaxes.h +++ b/lib/jkqtplotter/jkqtpcoordinateaxes.h @@ -494,7 +494,17 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject { public Q_SLOTS: /** \brief set range of plot axis */ void setRange(double amin, double amax); - /** \brief set absolute range of plot axis */ + /** \brief sets absolutely limiting range of the plot + * + * The user (or programmer) cannot zoom to a viewport that is larger than the range given to this function. + * + * \param aamin absolute minimum of the axis + * \param aamax absolute maximum of the axis + * + * \note if the aspect ratio (set in the JKQTBasePlotter or JKQTPlotter) of this does not fit into the widget, it is possible that you don't see the complete contents! + * + * \see setAbsoluteX(), setAbsoluteY(), zoomToFit(), JKQTPCoordinateAxis::setAbsoluteRange() + */ void setAbsoluteRange(double aamin, double aamax); /** \brief do not use an absolute range of plot axis */ void setNoAbsoluteRange(); diff --git a/lib/jkqtplotter/jkqtplotter.h b/lib/jkqtplotter/jkqtplotter.h index c6500f45c8..e94eb225bc 100644 --- a/lib/jkqtplotter/jkqtplotter.h +++ b/lib/jkqtplotter/jkqtplotter.h @@ -919,9 +919,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget { public Q_SLOTS: /** \brief set the current plot magnification */ void setMagnification(double m); - /** \copydoc JKQTBasePlotter::zoom() */ - inline void zoom(double nxmin, double nxmax, double nymin, double nymax) { - plotter->zoom(nxmin, nxmax, nymin, nymax); + /** \copydoc JKQTBasePlotter::zoom() + * \deprecated The function JKQTPlotter::zoom() is deprecated and will be removed in future version, use JKQTPlotter::setXY() instead! + */ + inline void zoom(double nxmin, double nxmax, double nymin, double nymax, bool affectsSecondaryAxes=false) { + plotter->zoom(nxmin, nxmax, nymin, nymax, affectsSecondaryAxes); } /** \copydoc JKQTBasePlotter::setGrid() */ @@ -972,10 +974,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget { inline void setShowZeroAxes(bool showX, bool showY) { plotter->setShowZeroAxes(showX, showY); } - /** \brief switches the visibility of the zero-axes associated with the x- and y-axis - * - * \param showXY indicates whether to show the zero-axis associated with the x- and y-axis - * */ + /** \copydoc JKQTBasePlotter::setShowZeroAxes() */ inline void setShowZeroAxes(bool showXY) { plotter->setShowZeroAxes(showXY); }