mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2025-01-12 00:40:32 +08:00
removed/breaking change: removed the overlay elements (derived from JKQTPOverlayElement), which were not very well set up and are more confusing than useful.
This commit is contained in:
parent
95d885bc2c
commit
ba856b594f
@ -211,7 +211,6 @@ This group assembles all classes that represent different elements of a plot (ma
|
||||
There are these major subgroups:
|
||||
- \ref jkqtpbaseplotter_elements contains all non-graph objects, i.e. things like coordinate axes and so on
|
||||
- \ref jkqtplotter_graphsgroup contains the actual graph classes
|
||||
- \ref jkqtplotter_overlays contains classes for overlay elements (lines, marker ...) that can be drawn quickly on top of a plot
|
||||
.
|
||||
|
||||
\defgroup jkqtpbaseplotter_elements Basic (non-graph) Plot Elements (coordinate axes, ...)
|
||||
@ -558,24 +557,6 @@ Examples:
|
||||
<td> JKQTPContourPlot, JKQTPColumnContourPlot
|
||||
</table>
|
||||
|
||||
\defgroup jkqtplotter_overlays Overlay Elements
|
||||
\ingroup jkqtplotter_elements
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th> Screenshot
|
||||
<th> Classes
|
||||
<tr>
|
||||
<td>
|
||||
<td> JKQTPOverlayVerticalLine, JKQTPOverlayLine
|
||||
<tr>
|
||||
<td>
|
||||
<td> JKQTPOverlayVerticalRange
|
||||
<tr>
|
||||
<td>
|
||||
<td> JKQTPOverlayRectangle
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
\defgroup jkqtpplotter_styling JKQTPlotter Styling System
|
||||
|
@ -20,10 +20,11 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
|
||||
<li> fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/41">#41: Build error when JKQtPlotter_BUILD_INCLUDE_XITS_FONTS set to OFF </a>, thanks to <a href="https://github.com/smistad">user:smistad</a></li>
|
||||
<li> fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/37">#37: CMake installs things into $PREFIX/doc/*.txt </a>, thanks to <a href="https://github.com/certik">user:certik</a></li>
|
||||
<li> fixed issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/45">#45: Build error on mac jkqtfastplotter.cpp:342:28: Variable has incomplete type 'QPainterPath'</a>, thanks to <a href="https://github.com/abdedixit">user:abdedixit</a></li>
|
||||
<li>removed the usage of some deprecated functions and objects (e.g. QMatrix)</li>
|
||||
<li>improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)</li>
|
||||
<li>removed/breaking change: removed the usage of some deprecated functions and objects (e.g. QMatrix)</li>
|
||||
<li>removed/breaking change: removed the overlay elements (derived from JKQTPOverlayElement), which were not very well set up and are more confusing than useful.</li>
|
||||
<li>improved/breaking change: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)</li>
|
||||
<li>improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)</li>
|
||||
<li>improved: reworked class hirarchy of parsed function plots and declared several setters as slots.</li>
|
||||
<li>improved/breaking change: reworked class hirarchy of parsed function plots and declared several setters as slots.</li>
|
||||
<li>new: added geometric plot objects JKQTPGeoArrow to draw arrows (aka lines with added line-end decorators, also extended JKQTPGeoLine, JKQTPGeoInfiniteLine, JKQTPGeoPolyLines to draw line-end decorator (aka arrows)</li>
|
||||
<li>new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves</li>
|
||||
<li>new: a new graph class JKQTPXYFunctionLineGraph draws parametric 2D curves ( \f$ [x,y] = f(t) \f$ ), see \ref JKQTPlotterEvalCurves for an example</li>
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/graphs/jkqtpcontour.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QDate>
|
||||
#include <QDateTime>
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/graphs/jkqtpscatter.h"
|
||||
|
||||
|
||||
|
||||
|
@ -11,12 +11,7 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -11,9 +11,6 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
|
@ -12,9 +12,6 @@
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
|
@ -16,16 +16,11 @@ TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
|
||||
ovlCnt=0;
|
||||
ovlTime.start();
|
||||
|
||||
|
||||
plot=new JKQTPlotter(true, this);
|
||||
plot->setPlotUpdateEnabled(false);
|
||||
plotBot=new JKQTPlotter(false, this, plot->getDatastore());
|
||||
plotBot2=new JKQTPlotter(false, this, plot->getDatastore());
|
||||
ovl1=new JKQTPOverlayVerticalLine(0.0, tr("test"), plot->getPlotter());
|
||||
plot->getPlotter()->addOverlayElement(ovl1);
|
||||
plot->setObjectName("plot");
|
||||
plotBot->setObjectName("plotBot");
|
||||
plotBot2->setObjectName("plotBot2");
|
||||
@ -309,33 +304,6 @@ TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) :
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QTimer::singleShot(50, this, SLOT(moveovl()));
|
||||
|
||||
}
|
||||
|
||||
void TestWidgetGraphs::moveovl() {
|
||||
ovl1->setPosition(ovl1->getPosition()+0.1);
|
||||
if (ovl1->getPosition()>30) ovl1->setPosition(0);
|
||||
ovlCnt++;
|
||||
if (ovlCnt>20) {
|
||||
double fps=double(ovlCnt)/(double(ovlTime.elapsed())/1000.0);
|
||||
ovl1->setText(QString("%1 fps").arg(fps));
|
||||
ovlCnt=0;
|
||||
ovlTime.start();
|
||||
}
|
||||
plot->redrawOverlays();
|
||||
QTimer::singleShot(10, this, SLOT(moveovl()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,9 +12,6 @@
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
@ -34,8 +31,7 @@ class TestWidgetGraphs : public QWidget
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void moveovl();
|
||||
protected slots:
|
||||
|
||||
void setErrorLineStyle(int index);
|
||||
void setESSymbol(int index);
|
||||
@ -53,7 +49,6 @@ class TestWidgetGraphs : public QWidget
|
||||
double b1[N3], b2[N3], b3[N3];
|
||||
|
||||
|
||||
JKQTPOverlayVerticalLine* ovl1;
|
||||
JKQTPlotter* plot;
|
||||
JKQTPlotter* plotLOG;
|
||||
JKQTPlotter* plotBot;
|
||||
@ -64,8 +59,6 @@ class TestWidgetGraphs : public QWidget
|
||||
JKQTPXYLineErrorGraph* pltePlot2;
|
||||
|
||||
|
||||
int ovlCnt;
|
||||
QElapsedTimer ovlTime;
|
||||
|
||||
|
||||
};
|
||||
|
@ -11,12 +11,7 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimage.h"
|
||||
#include "jkqtplotter/graphs/jkqtpimagergb.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/graphs/jkqtpparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/gui/jkqtpgraphsmodel.h"
|
||||
|
@ -24,7 +24,6 @@ isEmpty(JKQTP_PLOTTER_PRI_INCLUDED) {
|
||||
$$PWD/jkqtplotter/jkqtpcoordinateaxes.h \
|
||||
$$PWD/jkqtplotter/jkqtpcoordinateaxesstyle.h \
|
||||
$$PWD/jkqtplotter/jkqtpimagetools.h \
|
||||
$$PWD/jkqtplotter/jkqtpoverlaysbase.h \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpboxplot.h \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpboxplotstylingmixins.h \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpevaluatedfunctionbase.h \
|
||||
@ -51,7 +50,6 @@ isEmpty(JKQTP_PLOTTER_PRI_INCLUDED) {
|
||||
$$PWD/jkqtplotter/graphs/jkqtpspecialline.h \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpbarchart.h \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpevaluatedparametriccurve.h \
|
||||
$$PWD/jkqtplotter/overlays/jkqtpbasicoverlays.h \
|
||||
$$PWD/jkqtplotter/gui/jkqtpcomboboxes.h \
|
||||
$$PWD/jkqtplotter/gui/jkqtpenhancedspinboxes.h \
|
||||
$$PWD/jkqtplotter/gui/jkqtpenhancedtableview.h \
|
||||
@ -75,7 +73,6 @@ isEmpty(JKQTP_PLOTTER_PRI_INCLUDED) {
|
||||
$$PWD/jkqtplotter/jkqtpbaseplotterstyle.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpcoordinateaxes.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpcoordinateaxesstyle.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpoverlaysbase.cpp \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpboxplot.cpp \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpboxplotstylingmixins.cpp \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpevaluatedfunctionbase.cpp \
|
||||
@ -102,7 +99,6 @@ isEmpty(JKQTP_PLOTTER_PRI_INCLUDED) {
|
||||
$$PWD/jkqtplotter/graphs/jkqtpspecialline.cpp \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpbarchart.cpp \
|
||||
$$PWD/jkqtplotter/graphs/jkqtpevaluatedparametriccurve.cpp \
|
||||
$$PWD/jkqtplotter/overlays/jkqtpbasicoverlays.cpp \
|
||||
$$PWD/jkqtplotter/gui/jkqtpcomboboxes.cpp \
|
||||
$$PWD/jkqtplotter/gui/jkqtpenhancedspinboxes.cpp \
|
||||
$$PWD/jkqtplotter/gui/jkqtpenhancedtableview.cpp \
|
||||
|
@ -25,7 +25,6 @@ set(SOURCES
|
||||
jkqtpbaseelements.cpp
|
||||
jkqtpbaseplotter.cpp
|
||||
jkqtpdatastorage.cpp
|
||||
jkqtpoverlaysbase.cpp
|
||||
jkqtpgraphsbase.cpp
|
||||
jkqtpgraphsbaseerrors.cpp
|
||||
jkqtpgraphsbasestylingmixins.cpp
|
||||
@ -65,9 +64,6 @@ set(SOURCES_GRAPHS
|
||||
graphs/jkqtpstatisticsadaptors.cpp
|
||||
graphs/jkqtpevaluatedparametriccurve.cpp
|
||||
)
|
||||
set(SOURCES_OVERLAYS
|
||||
overlays/jkqtpbasicoverlays.cpp
|
||||
)
|
||||
set(SOURCES_GUI
|
||||
gui/jkqtpcomboboxes.cpp
|
||||
gui/jkqtpenhancedspinboxes.cpp
|
||||
@ -82,7 +78,6 @@ set(HEADERS
|
||||
jkqtpbaseelements.h
|
||||
jkqtpbaseplotter.h
|
||||
jkqtpdatastorage.h
|
||||
jkqtpoverlaysbase.h
|
||||
jkqtpgraphsbase.h
|
||||
jkqtpgraphsbaseerrors.h
|
||||
jkqtpgraphsbasestylingmixins.h
|
||||
@ -123,9 +118,6 @@ set(HEADERS_GRAPHS
|
||||
graphs/jkqtpbarchart.h
|
||||
graphs/jkqtpevaluatedparametriccurve.h
|
||||
)
|
||||
set(HEADERS_OVERLAY
|
||||
overlays/jkqtpbasicoverlays.h
|
||||
)
|
||||
set(HEADERS_GUI
|
||||
gui/jkqtpcomboboxes.h
|
||||
gui/jkqtpenhancedspinboxes.h
|
||||
@ -143,7 +135,7 @@ include(CMakePackageConfigHelpers)
|
||||
|
||||
|
||||
if(JKQtPlotter_BUILD_SHARED_LIBS)
|
||||
add_library(${libsh_name} SHARED ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${SOURCES_OVERLAYS} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${HEADERS_OVERLAYS} ${RESOURCES})
|
||||
add_library(${libsh_name} SHARED ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${RESOURCES})
|
||||
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
|
||||
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
|
||||
target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::Svg Qt5::Xml JKQTCommonSharedLib JKQTMathTextSharedLib)
|
||||
@ -171,7 +163,7 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
|
||||
endif()
|
||||
|
||||
if(JKQtPlotter_BUILD_STATIC_LIBS)
|
||||
add_library(${lib_name} STATIC ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${SOURCES_OVERLAYS} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${HEADERS_OVERLAYS} ${RESOURCES})
|
||||
add_library(${lib_name} STATIC ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${RESOURCES})
|
||||
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
|
||||
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
|
||||
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
|
||||
@ -252,10 +244,6 @@ install(FILES ${HEADERS_GUI}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}/gui
|
||||
COMPONENT Headers)
|
||||
|
||||
install(FILES ${HEADERS_OVERLAY}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}/overlays
|
||||
COMPONENT Headers)
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/readme.txt.in ${CMAKE_CURRENT_BINARY_DIR}/${lib_name}_Readme.txt @ONLY)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}_Readme.txt" DESTINATION doc/JKQtPlotter )
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/LICENSE" DESTINATION doc/JKQtPlotter RENAME "${lib_name}_LICENSE.txt" )
|
||||
|
@ -1205,7 +1205,7 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
|
||||
|
||||
void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays) {
|
||||
void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::paintPlot");
|
||||
#endif
|
||||
@ -1283,7 +1283,6 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays)
|
||||
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText);
|
||||
if (plotterStyle.keyStyle.visible) drawKey(painter);
|
||||
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText);
|
||||
if (showOverlays) drawOverlaysWithHints(painter);
|
||||
|
||||
if (plotterStyle.debugShowRegionBoxes) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
@ -1312,31 +1311,6 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays)
|
||||
//qDebug()<<" end JKQTBasePlotter::paintPlot";
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::drawOverlaysWithHints(JKQTPEnhancedPainter &painter) {
|
||||
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
|
||||
painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForGraphs);
|
||||
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText);
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::drawOverlaysWithHints");
|
||||
#endif
|
||||
if (overlays.isEmpty()) return;
|
||||
if (useClipping) {
|
||||
QRegion cregion(static_cast<int>(internalPlotBorderLeft), static_cast<int>(internalPlotBorderTop), static_cast<int>(internalPlotWidth), static_cast<int>(internalPlotHeight));
|
||||
painter.setClipping(true);
|
||||
painter.setClipRegion(cregion);
|
||||
}
|
||||
|
||||
for (int j=0; j<overlays.size(); j++) {
|
||||
JKQTPOverlayElement* g=overlays[j];
|
||||
if (g->isVisible()) g->draw(painter);
|
||||
}
|
||||
|
||||
if (useClipping) {
|
||||
painter.setClipping(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::gridPrintingCalc() {
|
||||
gridPrintingRows.clear();
|
||||
@ -1380,7 +1354,7 @@ void JKQTBasePlotter::gridPrintingCalc() {
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool showOverlays, bool scaleIfTooLarge, bool scaleIfTooSmall) {
|
||||
void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool scaleIfTooLarge, bool scaleIfTooSmall) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::gridPaint");
|
||||
#endif
|
||||
@ -1399,7 +1373,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
// scale the plot so it fits on the page
|
||||
painter.scale(scale, scale);
|
||||
drawPlot(painter, showOverlays);
|
||||
drawPlot(painter);
|
||||
|
||||
} else {
|
||||
|
||||
@ -1440,7 +1414,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
|
||||
for (size_t i=0; i<gridPrintingCurrentY; i++) { t_y+= static_cast<int>(gridPrintingRows[static_cast<int>(i)]); }
|
||||
//std::cout<<"printing this @ "<<t_x<<", "<<t_y<<" ...\n";
|
||||
painter.translate(t_x, t_y);
|
||||
drawPlot(painter, showOverlays);
|
||||
drawPlot(painter);
|
||||
|
||||
//std::cout<<"this printed ...\n";
|
||||
|
||||
@ -1456,7 +1430,7 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
|
||||
for (size_t j=0; j<gridPrintingList[i].y; j++) { gt_y+= static_cast<int>(gridPrintingRows[static_cast<int>(j)]); }
|
||||
//std::cout<<"printing "<<i<<" @ "<<t_x<<", "<<t_y<<" ...\n";
|
||||
painter.translate(gt_x, gt_y);
|
||||
gridPrintingList[i].plotter->drawPlot(painter, showOverlays);
|
||||
gridPrintingList[i].plotter->drawPlot(painter);
|
||||
|
||||
}
|
||||
|
||||
@ -1475,64 +1449,6 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
|
||||
}
|
||||
|
||||
|
||||
void JKQTBasePlotter::gridPaintOverlays(JKQTPEnhancedPainter &painter, QSizeF pageRect)
|
||||
{
|
||||
if (!gridPrinting) {
|
||||
double scale=static_cast<double>(pageRect.width())/static_cast<double>(widgetWidth)*paintMagnification;
|
||||
if (/*(scale*static_cast<double>(widgetWidth)/paintMagnification>static_cast<double>(pageRect.width())) ||*/ (scale*static_cast<double>(widgetHeight)>static_cast<double>(pageRect.height()))) {
|
||||
scale=static_cast<double>(pageRect.height())/static_cast<double>(widgetHeight);
|
||||
}
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
// scale the plot so it fits on the page
|
||||
painter.scale(scale, scale);
|
||||
drawOverlaysWithHints(painter);
|
||||
|
||||
} else {
|
||||
gridPrintingCalc(); // ensure the grid plot has been calculated
|
||||
// scale the plot so it fits on the page
|
||||
double scale=static_cast<double>(pageRect.width())/static_cast<double>(gridPrintingSize.width());
|
||||
if (/*(scale*static_cast<double>(gridPrintingSize.width())>static_cast<double>(pageRect.width())) ||*/ (scale*static_cast<double>(gridPrintingSize.height())>static_cast<double>(pageRect.height()))) {
|
||||
scale=static_cast<double>(pageRect.height())/static_cast<double>(gridPrintingSize.height());
|
||||
}
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.scale(scale, scale);
|
||||
|
||||
{
|
||||
// plot this plotter
|
||||
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
|
||||
size_t t_x=0;
|
||||
size_t t_y=0;
|
||||
//std::cout<<"printing this ...\n";
|
||||
for (size_t i=0; i<gridPrintingCurrentX; i++) { t_x+=gridPrintingColumns[static_cast<int>(i)]; }
|
||||
for (size_t i=0; i<gridPrintingCurrentY; i++) { t_y+=gridPrintingRows[static_cast<int>(i)]; }
|
||||
//std::cout<<"printing this @ "<<t_x<<", "<<t_y<<" ...\n";
|
||||
painter.translate(t_x, t_y);
|
||||
drawOverlaysWithHints(painter);
|
||||
|
||||
//std::cout<<"this printed ...\n";
|
||||
|
||||
// plot all the other plotters
|
||||
for (int i=0; i< gridPrintingList.size(); i++) {
|
||||
//std::cout<<"printing "<<i<<" ...\n";
|
||||
painter.save(); auto __finalpaintinnerloop=JKQTPFinally([&painter]() {painter.restore();});
|
||||
int gt_x=0;
|
||||
int gt_y=0;
|
||||
//std::cout<<"printing "<<i<<" @g "<<gridPrintingList[i].x<<", "<<gridPrintingList[i].y<<" ...\n";
|
||||
//std::cout<<"colrowlistsizes "<<gridPrintingColumns.size()<<", "<<gridPrintingRows.size()<<" ...\n";
|
||||
for (size_t j=0; j<gridPrintingList[i].x; j++) { gt_x+= static_cast<int>(gridPrintingColumns[static_cast<int>(j)]); }
|
||||
for (size_t j=0; j<gridPrintingList[i].y; j++) { gt_y+= static_cast<int>(gridPrintingRows[static_cast<int>(j)]); }
|
||||
//std::cout<<"printing "<<i<<" @ "<<t_x<<", "<<t_y<<" ...\n";
|
||||
painter.translate(gt_x, gt_y);
|
||||
gridPrintingList[i].plotter->drawOverlaysWithHints(painter);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JKQTBasePlotter::print(QPrinter* printer, bool displayPreview) {
|
||||
loadUserSettings();
|
||||
@ -2041,7 +1957,7 @@ void JKQTBasePlotter::printpreviewPaintRequested(QPrinter* printer) {
|
||||
qDebug()<<"x-axis label fontsize = "<<xAxis->getLabelFontSize()<<" pt";
|
||||
qDebug()<<"y-axis label fontsize = "<<yAxis->getLabelFontSize()<<" pt";
|
||||
#endif
|
||||
gridPaint(painter, printer->pageRect().size(), true, printScaleToPagesize, printScaleToPagesize);
|
||||
gridPaint(painter, printer->pageRect().size(), printScaleToPagesize, printScaleToPagesize);
|
||||
painter.end();
|
||||
widgetWidth=oldWidgetWidth;
|
||||
widgetHeight=oldWidgetHeight;
|
||||
@ -2141,9 +2057,9 @@ void JKQTBasePlotter::printpreviewPaintRequestedNew(QPaintDevice *paintDevice)
|
||||
qDebug()<<"x-axis label fontsize = "<<xAxis->getLabelFontSize()<<" pt";
|
||||
qDebug()<<"y-axis label fontsize = "<<yAxis->getLabelFontSize()<<" pt";
|
||||
#endif
|
||||
if (printer) gridPaint(painter, printer->pageRect().size(), true, printScaleToPagesize, printScaleToPagesize);
|
||||
else if (svg) gridPaint(painter, svg->size(), true, printScaleToPagesize, printScaleToPagesize);
|
||||
else gridPaint(painter, QSizeF(paintDevice->width(), paintDevice->height()), true, printScaleToPagesize, printScaleToPagesize);
|
||||
if (printer) gridPaint(painter, printer->pageRect().size(), printScaleToPagesize, printScaleToPagesize);
|
||||
else if (svg) gridPaint(painter, svg->size(), printScaleToPagesize, printScaleToPagesize);
|
||||
else gridPaint(painter, QSizeF(paintDevice->width(), paintDevice->height()), printScaleToPagesize, printScaleToPagesize);
|
||||
painter.end();
|
||||
widgetWidth=oldWidgetWidth;
|
||||
widgetHeight=oldWidgetHeight;
|
||||
@ -2289,9 +2205,9 @@ void JKQTBasePlotter::printpreviewUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QRect& rect, bool showOverlays) {
|
||||
void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QRect& rect) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::draw(rect, %1)").arg(showOverlays));
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::draw(rect, %1)"));
|
||||
#endif
|
||||
bool oldEmitPlotSignals=emitPlotSignals;
|
||||
emitPlotSignals=false;
|
||||
@ -2310,7 +2226,7 @@ void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QRect& rect, boo
|
||||
QElapsedTimer time;
|
||||
time.start();
|
||||
#endif
|
||||
gridPaint(painter, rect.size(), showOverlays);
|
||||
gridPaint(painter, rect.size());
|
||||
#ifdef JKQTBP_DEBUGTIMING
|
||||
qDebug()<<on<<"::draw ... gridPaint = " <<time.nsecsElapsed()/1000<<" usecs = "<<static_cast<double>(time.nsecsElapsed())/1000000.0<<" msecs";
|
||||
#endif
|
||||
@ -2318,21 +2234,10 @@ void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QRect& rect, boo
|
||||
emitPlotSignals=oldEmitPlotSignals;
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::drawOverlays(JKQTPEnhancedPainter &painter, const QRect& rect)
|
||||
{
|
||||
|
||||
//resize(rect.width(), rect.height());
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.translate(rect.topLeft());
|
||||
|
||||
gridPaintOverlays(painter, rect.size());
|
||||
|
||||
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QPoint& pos, bool showOverlays) {
|
||||
void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QPoint& pos) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::draw(pos, %1)").arg(showOverlays));
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::draw(pos, %1)"));
|
||||
#endif
|
||||
bool oldEmitPlotSignals=emitPlotSignals;
|
||||
emitPlotSignals=false;
|
||||
@ -2351,7 +2256,7 @@ void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QPoint& pos, boo
|
||||
QElapsedTimer time;
|
||||
time.start();
|
||||
#endif
|
||||
gridPaint(painter, rect.size(), showOverlays);
|
||||
gridPaint(painter, rect.size());
|
||||
#ifdef JKQTBP_DEBUGTIMING
|
||||
qDebug()<<on<<"::draw ... gridPaint = " <<time.nsecsElapsed()/1000<<" usecs = "<<static_cast<double>(time.nsecsElapsed())/1000000.0<<" msecs";
|
||||
#endif
|
||||
@ -2359,9 +2264,9 @@ void JKQTBasePlotter::draw(JKQTPEnhancedPainter& painter, const QPoint& pos, boo
|
||||
emitPlotSignals=oldEmitPlotSignals;
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect, bool showOverlays) {
|
||||
void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGrid(rect, %1)").arg(showOverlays));
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGrid(rect, %1)"));
|
||||
#endif
|
||||
bool oldEmitPlotSignals=emitPlotSignals;
|
||||
emitPlotSignals=false;
|
||||
@ -2393,7 +2298,7 @@ void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& re
|
||||
#ifdef JKQTBP_DEBUGTIMING
|
||||
time.start();
|
||||
#endif
|
||||
drawPlot(painter, showOverlays);
|
||||
drawPlot(painter);
|
||||
#ifdef JKQTBP_DEBUGTIMING
|
||||
qDebug()<<on<<"::drawNonGrid ... paintPlot = " <<time.nsecsElapsed()/1000<<" usecs = "<<static_cast<double>(time.nsecsElapsed())/1000000.0<<" msecs";
|
||||
#endif
|
||||
@ -2407,9 +2312,9 @@ void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& re
|
||||
}
|
||||
|
||||
|
||||
void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos, bool showOverlays) {
|
||||
void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGrid(pos, %1)").arg(showOverlays));
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGrid(pos)"));
|
||||
#endif
|
||||
bool oldEmitPlotSignals=emitPlotSignals;
|
||||
emitPlotSignals=false;
|
||||
@ -2442,7 +2347,7 @@ void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& p
|
||||
#ifdef JKQTBP_DEBUGTIMING
|
||||
time.start();
|
||||
#endif
|
||||
drawPlot(painter, showOverlays);
|
||||
drawPlot(painter);
|
||||
#ifdef JKQTBP_DEBUGTIMING
|
||||
qDebug()<<on<<"::drawNonGrid ... paintPlot = " <<time.nsecsElapsed()/1000<<" usecs = "<<static_cast<double>(time.nsecsElapsed())/1000000.0<<" msecs";
|
||||
#endif
|
||||
@ -2455,27 +2360,6 @@ void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& p
|
||||
emitPlotSignals=oldEmitPlotSignals;
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::drawNonGridOverlays(JKQTPEnhancedPainter& painter, const QPoint& pos) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTBasePlotter::drawNonGridOverlays(point)"));
|
||||
#endif
|
||||
QRectF rect(pos, QSizeF(widgetWidth/paintMagnification, widgetHeight/paintMagnification));
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.translate(rect.topLeft());
|
||||
double scale=static_cast<double>(rect.width())/static_cast<double>(widgetWidth)*paintMagnification;
|
||||
if ((scale*static_cast<double>(widgetWidth)/paintMagnification>static_cast<double>(rect.width())) || (scale*static_cast<double>(widgetHeight)/paintMagnification>static_cast<double>(rect.height()))) {
|
||||
scale=static_cast<double>(rect.height())/static_cast<double>(widgetHeight)*paintMagnification;
|
||||
}
|
||||
{
|
||||
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
|
||||
// scale the plot so it fits on the page
|
||||
painter.scale(scale, scale);
|
||||
drawOverlaysWithHints(painter);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::setEmittingPlotSignalsEnabled(bool __value)
|
||||
{
|
||||
this->emitPlotSignals = __value;
|
||||
@ -4719,84 +4603,6 @@ void JKQTBasePlotter::zoomToFit(bool zoomX, bool zoomY, bool includeX0, bool inc
|
||||
|
||||
|
||||
|
||||
JKQTPOverlayElement *JKQTBasePlotter::getOverlayElement(size_t i) {
|
||||
return overlays[static_cast<int>(i)];
|
||||
}
|
||||
|
||||
size_t JKQTBasePlotter::getOverlayElementCount() {
|
||||
return static_cast<size_t>(overlays.size());
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::deleteOverlayElement(size_t i, bool deletegraph) {
|
||||
if (long(i)<0 || long(i)>=overlays.size()) return;
|
||||
JKQTPOverlayElement* g=overlays[static_cast<int>(i)];
|
||||
overlays.removeAt(static_cast<int>(i));
|
||||
if (deletegraph && g) delete g;
|
||||
if (emitPlotSignals) emit overlaysUpdated();
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::deleteOverlayElement(JKQTPOverlayElement *gr, bool deletegraph) {
|
||||
int i=overlays.indexOf(gr);
|
||||
while (i>=0) {
|
||||
overlays.removeAt(i);
|
||||
i=overlays.indexOf(gr);
|
||||
}
|
||||
|
||||
if (deletegraph && gr) delete gr;
|
||||
if (emitPlotSignals) emit overlaysUpdated();
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::clearOverlayElement(bool deleteGraphs) {
|
||||
for (int i=0; i<overlays.size(); i++) {
|
||||
JKQTPOverlayElement* g=overlays[i];
|
||||
if (g && deleteGraphs) delete g;
|
||||
}
|
||||
overlays.clear();
|
||||
if (emitPlotSignals) emit overlaysUpdated();
|
||||
}
|
||||
|
||||
size_t JKQTBasePlotter::addOverlayElement(JKQTPOverlayElement *gr) {
|
||||
gr->setParent(this);
|
||||
for (size_t i=0; i<static_cast<size_t>(overlays.size()); i++) {
|
||||
if (overlays[static_cast<int>(i)]==gr) return i;
|
||||
}
|
||||
overlays.push_back(gr);
|
||||
if (emitPlotSignals) emit overlaysUpdated();
|
||||
return static_cast<size_t>(overlays.size()-1);
|
||||
}
|
||||
|
||||
bool JKQTBasePlotter::containsOverlayElement(JKQTPOverlayElement *gr) const {
|
||||
for (int i=0; i<overlays.size(); i++) {
|
||||
if (overlays[i]==gr) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t JKQTBasePlotter::moveOverlayElementTop(JKQTPOverlayElement *gr) {
|
||||
gr->setParent(this);
|
||||
for (int i=0; i<overlays.size(); i++) {
|
||||
if (overlays[i]==gr) {
|
||||
if (i<overlays.size()-1) {
|
||||
overlays.removeAt(i);
|
||||
overlays.push_back(gr);
|
||||
}
|
||||
return static_cast<size_t>(overlays.size()-1);
|
||||
}
|
||||
}
|
||||
overlays.push_back(gr);
|
||||
if (emitPlotSignals) emit overlaysUpdated();
|
||||
return static_cast<size_t>(overlays.size()-1);
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::addOverlayElements(const QList<JKQTPOverlayElement *> &gr) {
|
||||
for (int i=0; i< gr.size(); i++) {
|
||||
addOverlayElement(gr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "jkqtplotter/jkqtpbaseplotterstyle.h"
|
||||
#include "jkqtmathtext/jkqtmathtext.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtcommon/jkqtpenhancedpainter.h"
|
||||
#include "jkqtplotter/gui/jkqtpenhancedspinboxes.h"
|
||||
|
||||
@ -98,7 +97,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPaintDeviceAdapter {
|
||||
* -# 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
|
||||
* .
|
||||
@ -620,48 +618,33 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
/*! \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
|
||||
\param showOverlays decides whether to draw overlays
|
||||
*/
|
||||
void draw(JKQTPEnhancedPainter& painter, const QRect& rect, bool showOverlays=true);
|
||||
void draw(JKQTPEnhancedPainter& painter, const 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, const QPoint& pos=QPoint(0,0));
|
||||
|
||||
/*! \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, const QRect& rect);
|
||||
void drawNonGrid(JKQTPEnhancedPainter& painter, const 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)
|
||||
\param showOverlays decides whether to draw overlays
|
||||
*/
|
||||
void draw(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool showOverlays=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
|
||||
\param showOverlays decides whether to draw overlays
|
||||
*/
|
||||
void drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& rect, bool showOverlays=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)
|
||||
\param showOverlays decides whether to draw overlays
|
||||
*/
|
||||
void drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0), bool showOverlays=true);
|
||||
/*! \brief draw the contained graph overlays (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 drawNonGridOverlays(JKQTPEnhancedPainter &painter, const QPoint& pos=QPoint(0,0));
|
||||
void drawNonGrid(JKQTPEnhancedPainter& painter, const QPoint& pos=QPoint(0,0));
|
||||
|
||||
/** \brief emit plotUpdated() */
|
||||
void redrawPlot() { if (emitPlotSignals) emit plotUpdated(); }
|
||||
|
||||
/** \brief controls, whether the signals plotUpdated() and overlaysUpdated() are emitted */
|
||||
/** \brief controls, whether the signals plotUpdated() are emitted */
|
||||
void setEmittingPlotSignalsEnabled(bool __value);
|
||||
/** \brief returns, whether the signals plotUpdated() and overlaysUpdated() are emitted */
|
||||
/** \brief returns, whether the signals plotUpdated() are emitted */
|
||||
bool isEmittingPlotSignalsEnabled() const;
|
||||
|
||||
/** \copydoc JKQTBasePlotterStyle::plotBorderTop */
|
||||
@ -1021,35 +1004,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
|
||||
|
||||
|
||||
/** \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<JKQTPOverlayElement*>& gr);
|
||||
|
||||
/** \brief save the current plot data as a Comma Separated Values (CSV) file
|
||||
*
|
||||
@ -1129,9 +1083,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
/** \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();
|
||||
|
||||
@ -1631,9 +1582,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
/** \brief paints the plot onto the given JKQTPEnhancedPainter object
|
||||
*
|
||||
* \param painter JKQTPEnhancedPainter to draw on
|
||||
* \param showOverlays decides whether to draw overlays
|
||||
*/
|
||||
void drawPlot(JKQTPEnhancedPainter& painter, bool showOverlays=true);
|
||||
void drawPlot(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
|
||||
@ -1641,12 +1591,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
*
|
||||
* \param painter JKQTPEnhancedPainter to draw on
|
||||
* \param pageRect size of the page
|
||||
* \param showOverlays decides whether to draw overlays
|
||||
* \param scaleIfTooLarge scale image if it is too large for pageRect
|
||||
* \param scaleIfTooSmall scale image if it is smaller than pageRect
|
||||
*/
|
||||
void gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool showOverlays=true, bool scaleIfTooLarge=true, bool scaleIfTooSmall=true);
|
||||
void gridPaintOverlays(JKQTPEnhancedPainter& painter, QSizeF pageRect);
|
||||
void gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect, bool scaleIfTooLarge=true, bool scaleIfTooSmall=true);
|
||||
|
||||
/** \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
|
||||
@ -1664,8 +1612,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
void drawGraphs(JKQTPEnhancedPainter& painter);
|
||||
/** \brief plot a key */
|
||||
void drawKey(JKQTPEnhancedPainter& painter);
|
||||
/** \brief plot all overlay elements, also sets the render hints in \a painter */
|
||||
void drawOverlaysWithHints(JKQTPEnhancedPainter& painter);
|
||||
|
||||
/** \brief plot the key contents
|
||||
*
|
||||
@ -2064,10 +2010,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
QList<JKQTPPlotElement*> graphs;
|
||||
|
||||
|
||||
QList<JKQTPOverlayElement*> overlays;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** \brief indicates whether to use clipping (hack for printing, see print() ) */
|
||||
@ -2125,7 +2067,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
bool masterSynchronizeHeight;
|
||||
|
||||
|
||||
/** \brief controls, whether the signals plotUpdated() and overlaysUpdated() are emitted */
|
||||
/** \brief controls, whether the signals plotUpdated() are emitted */
|
||||
bool emitPlotSignals;
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ JKQTPlotter::JKQTPlotter(bool datastore_internal, QWidget* parent, JKQTPDatastor
|
||||
mouseDragRectYEndPixel(0), mouseDragRectXEnd(0), mouseDragRectYStart(0),
|
||||
mouseDragRectYStartPixel(0), mouseDragRectYEnd(0),
|
||||
mouseDragMarkers(),
|
||||
image(), imageNoOverlays(), oldImage(),
|
||||
image(), oldImage(),
|
||||
menuSpecialContextMenu(nullptr),toolbar(nullptr), masterPlotterX(nullptr), masterPlotterY(nullptr),
|
||||
mousePosX(0), mousePosY(0),
|
||||
magnification(1),
|
||||
@ -75,13 +75,11 @@ JKQTPlotter::JKQTPlotter(bool datastore_internal, QWidget* parent, JKQTPDatastor
|
||||
|
||||
|
||||
connect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot()));
|
||||
connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays()));
|
||||
connect(plotter, SIGNAL(beforePlotScalingRecalculate()), this, SLOT(intBeforePlotScalingRecalculate()));
|
||||
connect(plotter, SIGNAL(zoomChangedLocally(double, double, double, double, JKQTBasePlotter*)), this, SLOT(pzoomChangedLocally(double, double, double, double, JKQTBasePlotter*)));
|
||||
|
||||
image=QImage(width(), height(), QImage::Format_ARGB32);
|
||||
oldImage=image;
|
||||
imageNoOverlays=image;
|
||||
|
||||
// enable mouse-tracking, so mouseMoved-Events can be caught
|
||||
setMouseTracking(true);
|
||||
@ -149,7 +147,6 @@ JKQTPlotter::JKQTPlotter(QWidget *parent):
|
||||
JKQTPlotter::~JKQTPlotter() {
|
||||
resetContextMenu(false);
|
||||
disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot()));
|
||||
disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays()));
|
||||
disconnect(plotter, SIGNAL(beforePlotScalingRecalculate()), this, SLOT(intBeforePlotScalingRecalculate()));
|
||||
disconnect(plotter, SIGNAL(zoomChangedLocally(double, double, double, double, JKQTBasePlotter*)), this, SLOT(pzoomChangedLocally(double, double, double, double, JKQTBasePlotter*)));
|
||||
delete plotter;
|
||||
@ -1123,24 +1120,6 @@ void JKQTPlotter::synchronizeXYAxis(double newxmin, double newxmax, double newym
|
||||
setXY(newxmin, newxmax, newymin, newymax);
|
||||
}
|
||||
|
||||
void JKQTPlotter::redrawOverlays() {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot(QString("JKQTPlotter::redrawOverlays()"));
|
||||
#endif
|
||||
if (!doDrawing) return;
|
||||
disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot()));
|
||||
disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays()));
|
||||
image=imageNoOverlays;
|
||||
JKQTPEnhancedPainter painter(&image);
|
||||
if (painter.isActive()) {
|
||||
painter.scale(magnification, magnification);
|
||||
plotter->drawNonGridOverlays(painter);
|
||||
}
|
||||
oldImage=image;
|
||||
connect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot()));
|
||||
connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays()));
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
void JKQTPlotter::redrawPlot() {
|
||||
@ -1149,21 +1128,17 @@ void JKQTPlotter::redrawPlot() {
|
||||
#endif
|
||||
if (!doDrawing) return;
|
||||
disconnect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot()));
|
||||
disconnect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays()));
|
||||
plotter->setWidgetSize(jkqtp_roundTo<int>(width()/magnification), jkqtp_roundTo<int>(height()/magnification-getPlotYOffset()));
|
||||
JKQTPEnhancedPainter painter(&image);
|
||||
if (painter.isActive()) {
|
||||
painter.scale(magnification, magnification);
|
||||
//QTime t;
|
||||
//t.start();
|
||||
plotter->drawNonGrid(painter, QPoint(0,0), false);//, QRect(QPoint(0,0), QSize(plotter->getPlotWidth(), plotter->getPlotHeight())));
|
||||
plotter->drawNonGrid(painter, QPoint(0,0));//, QRect(QPoint(0,0), QSize(plotter->getPlotWidth(), plotter->getPlotHeight())));
|
||||
//qDebug()<<"drawNonGrid"<<objectName()<<": "<<t.elapsed()<<"ms";
|
||||
imageNoOverlays=image;
|
||||
plotter->drawNonGridOverlays(painter);
|
||||
}
|
||||
oldImage=image;
|
||||
connect(plotter, SIGNAL(plotUpdated()), this, SLOT(redrawPlot()));
|
||||
connect(plotter, SIGNAL(overlaysUpdated()), this, SLOT(redrawOverlays()));
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -1034,14 +1034,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget {
|
||||
/** \brief update the plot and the overlays */
|
||||
void redrawPlot();
|
||||
|
||||
/** \brief replot overlays only (use redrawPlot() to replot the plot and the overlays)
|
||||
*
|
||||
* You can use this function, if you only changed the overlays but not the graphs in this plotter.
|
||||
* Then only the overlas are redrawn and the old (saved) image of the graphs and the coordinate syste,
|
||||
* is used as a base. This is significantly faster than redrawing the whole plot.
|
||||
*/
|
||||
void redrawOverlays();
|
||||
|
||||
/** \brief allows to activate/deactivate toolbar buttons that can activate certain mouse drag actions
|
||||
*
|
||||
* \see getActMouseLeftAsDefault(), getActMouseLeftAsRuler(), getActMouseLeftAsToolTip()
|
||||
@ -1498,9 +1490,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget {
|
||||
/** \brief this stores the currently displayed plot */
|
||||
QImage image;
|
||||
|
||||
/** \brief this stores the currently displayed plot */
|
||||
QImage imageNoOverlays;
|
||||
|
||||
/** \brief this can be used when drawing a zoom rectangle to store an unchanged
|
||||
* copy of the currently displayed image.
|
||||
*/
|
||||
|
@ -1,176 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
|
||||
|
||||
|
||||
|
||||
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.1 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpoverlaysbase.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
#include "jkqtcommon/jkqtpdrawingtools.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
|
||||
JKQTPOverlayElement::JKQTPOverlayElement(JKQTBasePlotter *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
visible=true;
|
||||
}
|
||||
|
||||
void JKQTPOverlayElement::setParent(JKQTBasePlotter *parent) {
|
||||
this->parent=parent;
|
||||
QObject::setParent(parent);
|
||||
}
|
||||
|
||||
void JKQTPOverlayElement::setVisible(bool __value)
|
||||
{
|
||||
this->visible = __value;
|
||||
}
|
||||
|
||||
bool JKQTPOverlayElement::isVisible() const
|
||||
{
|
||||
return this->visible;
|
||||
}
|
||||
|
||||
QPointF JKQTPOverlayElement::transform(const QPointF &x) {
|
||||
return QPointF(parent->x2p(x.x()), parent->y2p(x.y()));
|
||||
}
|
||||
|
||||
double JKQTPOverlayElement::transfromX(double x)
|
||||
{
|
||||
return parent->x2p(x);
|
||||
}
|
||||
|
||||
double JKQTPOverlayElement::transfromY(double y)
|
||||
{
|
||||
return parent->y2p(y);
|
||||
}
|
||||
|
||||
QPointF JKQTPOverlayElement::backTransform(const QPointF &x) {
|
||||
return QPointF(parent->p2x(x.x()), parent->p2y(x.y()));
|
||||
}
|
||||
|
||||
QVector<QPointF> JKQTPOverlayElement::transform(const QVector<QPointF> &x) {
|
||||
QVector<QPointF> res;
|
||||
for (int i=0; i<x.size(); i++) {
|
||||
res.append(transform(x[i]));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
QPainterPath JKQTPOverlayElement::transformToLinePath(const QVector<QPointF> &x) {
|
||||
QPainterPath res;
|
||||
if (x.size()>0) {
|
||||
res.moveTo(transform(x[0]));
|
||||
for (int i=1; i<x.size(); i++) {
|
||||
res.lineTo(transform(x[i]));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPOverlayOneCoordOverlay::JKQTPOverlayOneCoordOverlay(double pos, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayElement(parent)
|
||||
{
|
||||
this->position=pos;
|
||||
}
|
||||
|
||||
void JKQTPOverlayOneCoordOverlay::setPosition(double __value)
|
||||
{
|
||||
this->position = __value;
|
||||
}
|
||||
|
||||
double JKQTPOverlayOneCoordOverlay::getPosition() const
|
||||
{
|
||||
return this->position;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPOverlayTwoCoordOverlay::JKQTPOverlayTwoCoordOverlay(double pos, double pos2, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayOneCoordOverlay(pos, parent)
|
||||
{
|
||||
position2=pos2;
|
||||
}
|
||||
|
||||
void JKQTPOverlayTwoCoordOverlay::setPosition2(double __value)
|
||||
{
|
||||
this->position2 = __value;
|
||||
}
|
||||
|
||||
double JKQTPOverlayTwoCoordOverlay::getPosition2() const
|
||||
{
|
||||
return this->position2;
|
||||
}
|
||||
|
||||
JKQTPOverlayTwoPositionOverlay::JKQTPOverlayTwoPositionOverlay(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayElement(parent)
|
||||
{
|
||||
this->x1=x1;
|
||||
this->y1=y1;
|
||||
this->x2=x2;
|
||||
this->y2=y2;
|
||||
}
|
||||
|
||||
void JKQTPOverlayTwoPositionOverlay::setX1(double __value)
|
||||
{
|
||||
this->x1 = __value;
|
||||
}
|
||||
|
||||
double JKQTPOverlayTwoPositionOverlay::getX1() const
|
||||
{
|
||||
return this->x1;
|
||||
}
|
||||
|
||||
void JKQTPOverlayTwoPositionOverlay::setX2(double __value)
|
||||
{
|
||||
this->x2 = __value;
|
||||
}
|
||||
|
||||
double JKQTPOverlayTwoPositionOverlay::getX2() const
|
||||
{
|
||||
return this->x2;
|
||||
}
|
||||
|
||||
void JKQTPOverlayTwoPositionOverlay::setY1(double __value)
|
||||
{
|
||||
this->y1 = __value;
|
||||
}
|
||||
|
||||
double JKQTPOverlayTwoPositionOverlay::getY1() const
|
||||
{
|
||||
return this->y1;
|
||||
}
|
||||
|
||||
void JKQTPOverlayTwoPositionOverlay::setY2(double __value)
|
||||
{
|
||||
this->y2 = __value;
|
||||
}
|
||||
|
||||
double JKQTPOverlayTwoPositionOverlay::getY2() const
|
||||
{
|
||||
return this->y2;
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
|
||||
|
||||
|
||||
|
||||
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.1 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
#include <QPair>
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtplotter_imexport.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
|
||||
|
||||
#ifndef jkqtpelementsoverlay_H
|
||||
#define jkqtpelementsoverlay_H
|
||||
|
||||
// forward declarations
|
||||
class JKQTBasePlotter;
|
||||
|
||||
/*! \brief this virtual base class describes an interface for graph overlay elements, which are simple geometric
|
||||
forms drawn ONTO the graphe, so a redraw of the overlays does NOT require a redraw of the graph.
|
||||
\ingroup jkqtplotter_overlays
|
||||
|
||||
These simple primitive elements can be used to e.g. display fast changing indicators on the graph ...
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayElement : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayElement(JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter)=0;
|
||||
|
||||
/** \brief returns the parent painter class */
|
||||
inline JKQTBasePlotter* getParent() { return parent; }
|
||||
|
||||
/** \brief sets the parent painter class */
|
||||
virtual void setParent(JKQTBasePlotter* parent);
|
||||
|
||||
|
||||
|
||||
/*! \copydoc visible */
|
||||
void setVisible(bool __value);
|
||||
/*! \copydoc visible */
|
||||
bool isVisible() const;
|
||||
|
||||
protected:
|
||||
/** \brief the plotter object this object belongs to */
|
||||
JKQTBasePlotter* parent;
|
||||
|
||||
/** \brief indictaes whether the overlay is visible (at all) */
|
||||
bool visible;
|
||||
|
||||
|
||||
/** \brief tool routine that transforms a QPointF according to the parent's transformation rules */
|
||||
QPointF transform(const QPointF& x);
|
||||
|
||||
double transfromX(double x);
|
||||
double transfromY(double y);
|
||||
|
||||
/** \brief tool routine that back-transforms a QPointF according to the parent's transformation rules */
|
||||
QPointF backTransform(const QPointF& x);
|
||||
|
||||
/** \brief tool routine that transforms a QPointF according to the parent's transformation rules */
|
||||
inline QPointF transform(double x, double y) {
|
||||
return transform(QPointF(x,y));
|
||||
}
|
||||
/** \brief tool routine that back-transforms a QPointF according to the parent's transformation rules */
|
||||
inline QPointF backTransform(double x, double y) {
|
||||
return backTransform(QPointF(x,y));
|
||||
}
|
||||
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules */
|
||||
QVector<QPointF> transform(const QVector<QPointF>& x);
|
||||
|
||||
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules
|
||||
* and returns a (non-closed) path consisting of lines */
|
||||
QPainterPath transformToLinePath(const QVector<QPointF>& x);
|
||||
|
||||
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules
|
||||
* and returns a polygon */
|
||||
inline QPolygonF transformToPolygon(const QVector<QPointF>& x) {
|
||||
return QPolygonF(transform(x));
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief baseclass for a two-position overlay
|
||||
\ingroup jkqtplotter_overlays
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayTwoPositionOverlay : public JKQTPOverlayElement {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayTwoPositionOverlay(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/*! \copydoc x1 */
|
||||
void setX1(double __value);
|
||||
/*! \copydoc x1 */
|
||||
double getX1() const;
|
||||
/*! \copydoc x2 */
|
||||
void setX2(double __value);
|
||||
/*! \copydoc x2 */
|
||||
double getX2() const;
|
||||
/*! \copydoc y1 */
|
||||
void setY1(double __value);
|
||||
/*! \copydoc y1 */
|
||||
double getY1() const;
|
||||
/*! \copydoc y2 */
|
||||
void setY2(double __value);
|
||||
/*! \copydoc y2 */
|
||||
double getY2() const;
|
||||
protected:
|
||||
/** \brief x-coordinate of first point of overlay */
|
||||
double x1;
|
||||
/** \brief y-coordinate of first point of overlay */
|
||||
double y1;
|
||||
/** \brief x-coordinate of first second of overlay */
|
||||
double x2;
|
||||
/** \brief y-coordinate of first second of overlay */
|
||||
double y2;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief baseclass for one-coordinate indicator overlays (horizontal/vertical lines
|
||||
\ingroup jkqtplotter_overlays
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayOneCoordOverlay : public JKQTPOverlayElement {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayOneCoordOverlay(double pos, JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/*! \copydoc position */
|
||||
void setPosition(double __value);
|
||||
/*! \copydoc position */
|
||||
double getPosition() const;
|
||||
protected:
|
||||
/** \brief second position for the element */
|
||||
double position;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief baseclass for two-coordinate indicator overlays (horizontal/vertical lines
|
||||
\ingroup jkqtplotter_overlays
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayTwoCoordOverlay : public JKQTPOverlayOneCoordOverlay {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayTwoCoordOverlay(double pos, double pos2, JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/*! \copydoc position2 */
|
||||
void setPosition2(double __value);
|
||||
/*! \copydoc position2 */
|
||||
double getPosition2() const;
|
||||
protected:
|
||||
/** \brief second position for the element */
|
||||
double position2;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // jkqtpelementsoverlay_H
|
@ -1,249 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
|
||||
|
||||
|
||||
|
||||
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.1 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/overlays/jkqtpbasicoverlays.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
#include "jkqtcommon/jkqtpdrawingtools.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
JKQTPOverlayVerticalLine::JKQTPOverlayVerticalLine(double pos, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayOneCoordOverlay(pos, parent), JKQTPGraphTextStyleMixin(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPOverlayVerticalLine::JKQTPOverlayVerticalLine(double pos, const QString& text, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayOneCoordOverlay(pos, parent), JKQTPGraphTextStyleMixin(parent)
|
||||
{
|
||||
setText(text);
|
||||
}
|
||||
|
||||
|
||||
void JKQTPOverlayVerticalLine::draw(JKQTPEnhancedPainter &painter) {
|
||||
if (!parent) return;
|
||||
double ymin=parent->getYMin();
|
||||
double ymax=parent->getYMax();
|
||||
QPointF p1=transform(position, ymin);
|
||||
QPointF p2=transform(position, ymax);
|
||||
QPointF p3=p2-QPointF(0, (p2.y()-p1.y())*0.1);
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.drawLine(p1, p2);
|
||||
|
||||
if (!text.isEmpty()) {
|
||||
|
||||
//JKQTMathText mt(this);
|
||||
JKQTMathText* mt=parent->getMathText();
|
||||
mt->setFontSize(getTextFontSize());
|
||||
mt->setFontColor(getTextColor());
|
||||
mt->setFontRomanOrSpecial(getTextFontName());
|
||||
mt->parse(text);
|
||||
mt->draw(painter, p3.x(), p3.y());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void JKQTPOverlayVerticalLine::setColor(QColor c)
|
||||
{
|
||||
setLineColor(c);
|
||||
setTextColor(c);
|
||||
}
|
||||
|
||||
void JKQTPOverlayVerticalLine::setText(const QString &__value)
|
||||
{
|
||||
this->text = __value;
|
||||
}
|
||||
|
||||
QString JKQTPOverlayVerticalLine::getText() const
|
||||
{
|
||||
return this->text;
|
||||
}
|
||||
|
||||
|
||||
JKQTPOverlayVerticalRange::JKQTPOverlayVerticalRange(double pos, double pos2, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayTwoCoordOverlay(pos, pos2, parent), JKQTPGraphTextStyleMixin(parent)
|
||||
{
|
||||
inverted=false;
|
||||
}
|
||||
|
||||
JKQTPOverlayVerticalRange::JKQTPOverlayVerticalRange(double pos, double pos2, const QString& text, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayTwoCoordOverlay(pos, pos2, parent), JKQTPGraphTextStyleMixin(parent)
|
||||
{
|
||||
setText(text);
|
||||
inverted=false;
|
||||
}
|
||||
|
||||
void JKQTPOverlayVerticalRange::draw(JKQTPEnhancedPainter &painter) {
|
||||
if (!parent) return;
|
||||
double ymin=parent->getYMin();
|
||||
double ymax=parent->getYMax();
|
||||
double xmin=parent->getXMin();
|
||||
double xmax=parent->getXMax();
|
||||
QPointF p1=transform(position, ymin);
|
||||
QPointF p2=transform(position, ymax);
|
||||
QPointF p3=p2-QPointF(0, (p2.y()-p1.y())*0.1);
|
||||
|
||||
QPointF p21=transform(position2, ymin);
|
||||
QPointF p22=transform(position2, ymax);
|
||||
//QPointF p23=p2-QPointF(0, (p2.y()-p1.y())*0.1);
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
if (getFillColor()!=QColor(Qt::transparent)) {
|
||||
if (inverted) {
|
||||
painter.fillRect(QRectF(transform(xmin, ymin), p2), getFillBrush(painter, parent));
|
||||
painter.fillRect(QRectF(p21, transform(xmax, ymax)), getFillBrush(painter, parent));
|
||||
} else {
|
||||
painter.fillRect(QRectF(p2, p21), getFillBrush(painter, parent));
|
||||
}
|
||||
}
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.drawLine(p1, p2);
|
||||
painter.drawLine(p21, p22);
|
||||
|
||||
if (!text.isEmpty()) {
|
||||
//JKQTMathText mt(this);
|
||||
JKQTMathText* mt=parent->getMathText();
|
||||
mt->setFontSize(getTextFontSize());
|
||||
mt->setFontColor(getTextColor());
|
||||
mt->setFontRomanOrSpecial(getTextFontName());
|
||||
mt->parse(text);
|
||||
mt->draw(painter, p3.x(), p3.y());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void JKQTPOverlayVerticalRange::setColor(QColor c)
|
||||
{
|
||||
setLineColor(c);
|
||||
setFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphFillColorDerivationMode, c));
|
||||
setTextColor(c);
|
||||
}
|
||||
|
||||
void JKQTPOverlayVerticalRange::setInverted(bool __value)
|
||||
{
|
||||
this->inverted = __value;
|
||||
}
|
||||
|
||||
bool JKQTPOverlayVerticalRange::getInverted() const
|
||||
{
|
||||
return this->inverted;
|
||||
}
|
||||
|
||||
void JKQTPOverlayVerticalRange::setText(const QString &__value)
|
||||
{
|
||||
text=__value;
|
||||
}
|
||||
|
||||
QString JKQTPOverlayVerticalRange::getText() const
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPOverlayLine::JKQTPOverlayLine(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayTwoPositionOverlay(x1,y1,x2,y2,parent)
|
||||
{
|
||||
infinite=false;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPOverlayLine::draw(JKQTPEnhancedPainter &painter) {
|
||||
if (!parent) return;
|
||||
double xmin=parent->getXMin();
|
||||
double xmax=parent->getXMax();
|
||||
QPointF p1=transform(x1, y1);
|
||||
QPointF p2=transform(x2, y2);
|
||||
|
||||
|
||||
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
if (infinite) {
|
||||
double alpha=(p2.y()-p1.y())/(p2.x()-p1.x());
|
||||
double offset=p1.y()-alpha*p1.x();
|
||||
|
||||
double pxmin=transfromX(xmin);
|
||||
double pxmax=transfromX(xmax);
|
||||
|
||||
QPointF pmin=QPointF(pxmin, pxmin*alpha+offset);
|
||||
QPointF pmax=QPointF(pxmax, pxmax*alpha+offset);
|
||||
painter.drawLine(pmin, pmax);
|
||||
} else {
|
||||
painter.drawLine(p1,p2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void JKQTPOverlayLine::setInfinite(bool __value)
|
||||
{
|
||||
this->infinite = __value;
|
||||
}
|
||||
|
||||
bool JKQTPOverlayLine::getInfinite() const
|
||||
{
|
||||
return this->infinite;
|
||||
}
|
||||
|
||||
void JKQTPOverlayLine::setColor(QColor c)
|
||||
{
|
||||
setLineColor(c);
|
||||
}
|
||||
|
||||
|
||||
JKQTPOverlayRectangle::JKQTPOverlayRectangle(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent):
|
||||
JKQTPOverlayTwoPositionOverlay(x1,y1,x2,y2,parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void JKQTPOverlayRectangle::draw(JKQTPEnhancedPainter &painter)
|
||||
{
|
||||
if (!parent) return;
|
||||
QPointF p1=transform(x1, y1);
|
||||
QPointF p2=transform(x2, y2);
|
||||
QRectF rect(qMin(p1.x(), p2.x()), qMin(p1.y(), p2.y()), fabs(p1.x()-p2.x()), fabs(p1.y()-p2.y()));
|
||||
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getFillBrush(painter, parent));
|
||||
//painter.fillRect(rect);
|
||||
painter.drawRect(rect);
|
||||
|
||||
}
|
||||
|
||||
void JKQTPOverlayRectangle::setColor(QColor c)
|
||||
{
|
||||
setLineColor(c);
|
||||
setFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphFillColorDerivationMode, c));
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2008-2020 Jan W. Krieger (<jan@jkrieger.de>)
|
||||
|
||||
|
||||
|
||||
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.1 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
#include <QPair>
|
||||
#include "jkqtplotter/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpoverlaysbase.h"
|
||||
#include "jkqtplotter/jkqtplotter_imexport.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
|
||||
|
||||
#ifndef jkqtpbasicoverlays_H
|
||||
#define jkqtpbasicoverlays_H
|
||||
|
||||
// forward declarations
|
||||
class JKQTBasePlotter;
|
||||
|
||||
|
||||
|
||||
/*! \brief draws a vertical line as an overlay
|
||||
\ingroup jkqtplotter_overlays
|
||||
|
||||
These simple primitive elements can be used to e.g. display fast changing indicators on the graph ...
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayVerticalLine : public JKQTPOverlayOneCoordOverlay, public JKQTPGraphLineStyleMixin, public JKQTPGraphTextStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayVerticalLine(double pos, JKQTBasePlotter *parent = nullptr);
|
||||
explicit JKQTPOverlayVerticalLine(double pos, const QString& text, JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter);
|
||||
/** \brief set element color */
|
||||
virtual void setColor(QColor c);
|
||||
|
||||
/*! \copydoc text */
|
||||
void setText(const QString & __value);
|
||||
/*! \copydoc text */
|
||||
QString getText() const;
|
||||
protected:
|
||||
/** \brief a text to display next to the vertical line */
|
||||
QString text;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief draws a vertical range as an overlay
|
||||
\ingroup jkqtplotter_overlays
|
||||
|
||||
These simple primitive elements can be used to e.g. display fast changing indicators on the graph ...
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayVerticalRange : public JKQTPOverlayTwoCoordOverlay, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin, public JKQTPGraphTextStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayVerticalRange(double pos, double pos2, JKQTBasePlotter *parent = nullptr);
|
||||
explicit JKQTPOverlayVerticalRange(double pos, double pos2, const QString& text, JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter);
|
||||
/** \brief set element color */
|
||||
virtual void setColor(QColor c);
|
||||
|
||||
/*! \copydoc inverted */
|
||||
void setInverted(bool __value);
|
||||
/*! \copydoc inverted */
|
||||
bool getInverted() const;
|
||||
|
||||
/*! \copydoc text */
|
||||
void setText(const QString & __value);
|
||||
/*! \copydoc text */
|
||||
QString getText() const;
|
||||
protected:
|
||||
/** \brief a text to display next to the range */
|
||||
QString text;
|
||||
/** \brief if set \c false, the range is filled, otherwise everything outside the range is filled */
|
||||
bool inverted;
|
||||
};
|
||||
|
||||
/*! \brief draws a line throught two points
|
||||
\ingroup jkqtplotter_overlays
|
||||
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayLine : public JKQTPOverlayTwoPositionOverlay, public JKQTPGraphLineStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayLine(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter);
|
||||
|
||||
/*! \copydoc infinite */
|
||||
void setInfinite(bool __value);
|
||||
/*! \copydoc infinite */
|
||||
bool getInfinite() const;
|
||||
/** \brief set element color */
|
||||
virtual void setColor(QColor c);
|
||||
protected:
|
||||
/** \brief the line goes on infinitely */
|
||||
bool infinite;
|
||||
};
|
||||
|
||||
/*! \brief draws a rectangle, spanned by two points
|
||||
\ingroup jkqtplotter_overlays
|
||||
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPOverlayRectangle : public JKQTPOverlayTwoPositionOverlay, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JKQTPOverlayRectangle(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent = nullptr);
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter);
|
||||
/** \brief set element color */
|
||||
virtual void setColor(QColor c);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif // jkqtpbasicoverlays_H
|
Loading…
Reference in New Issue
Block a user