reworked jkqtplot_test by splitting the single large CPP-file into several sub-components

This commit is contained in:
jkriege2 2018-11-18 14:24:29 +01:00
parent 3c8bdd71c7
commit f0249cf6eb
26 changed files with 2163 additions and 1479 deletions

View File

@ -247,7 +247,7 @@ class LIB_EXPORT JKQTPdatastore{
*/
template <typename TContainer>
size_t addCopiedColumn(const TContainer& data, const QString& name=QString("")) {
const size_t N=data.size();
const size_t N=static_cast<size_t>(data.size());
double* d=static_cast<double*>(malloc(static_cast<size_t>(N)*sizeof(double)));
if (N>0) {
size_t r=0;
@ -271,7 +271,7 @@ class LIB_EXPORT JKQTPdatastore{
*/
template <typename TContainer>
size_t addCopiedColumn(const TContainer& data, const QString& name, size_t stride, size_t start=0) {
const size_t N=(data.size()-start)/stride;
const size_t N=static_cast<size_t>(data.size()-start)/stride;
double* d=static_cast<double*>(malloc(static_cast<size_t>(N)*sizeof(double)));
if (N>0) {
size_t r=0;
@ -355,7 +355,7 @@ class LIB_EXPORT JKQTPdatastore{
/** \brief add one external column to the datastore. It contains \a width * \a height rows. The external data is assumed to be organized as a row-major image and is copied as such. The external data is copied to an internal array, so
* afterwards you can delete the external arrayThis returns its logical column ID.*/
template <typename T>
inline size_t addCopiedImageAsColumn(const T* data, size_t width, size_t height, const QString& name=QString(""), size_t stride=0, size_t start=0){
inline size_t addCopiedImageAsColumn(const T* data, size_t width, size_t height, const QString& name=QString(""), size_t stride=1, size_t start=0){
return addCopiedColumn<T>(data, width*height, stride, start, name);
}
@ -370,7 +370,7 @@ class LIB_EXPORT JKQTPdatastore{
/** \brief add one external column to the datastore. It contains \a width * \a height rows. The external data is assumed to be organized as a column-major image and is copied as row-major (i.e. is transposed). The external data is copied to an internal array, so
* afterwards you can delete the external arrayThis returns its logical column ID.*/
template <typename T>
size_t addCopiedImageAsColumnTranspose(const T* data, size_t width, size_t height, const QString& name=QString(""), size_t stride=0, size_t start=0){
size_t addCopiedImageAsColumnTranspose(const T* data, size_t width, size_t height, const QString& name=QString(""), size_t stride=1, size_t start=0){
double* temp=static_cast<T*>(malloc(width*height*sizeof(T)));
for (size_t x=0; x<width; x++) {
@ -390,7 +390,7 @@ class LIB_EXPORT JKQTPdatastore{
* afterwards you can delete the external arrayThis returns its logical column ID.*/
template <typename T>
inline size_t addCopiedImageAsColumnTranspose(const QVector<T>& data, size_t width, const QString& name=QString("")){
return addCopiedImageAsColumnTranspose<T>(data.data(), width, data.size()/width, name);
return addCopiedImageAsColumnTranspose<T>(data.data(), width, static_cast<size_t>(data.size())/width, name);
}
@ -429,7 +429,7 @@ class LIB_EXPORT JKQTPdatastore{
*/
template <typename TContainer, typename TContainerMask>
size_t addCopiedColumnMasked(const TContainer& data, const TContainerMask& mask, const QString& name=QString(""), bool useIfMaskEquals=false) {
const size_t N=data.size();
const size_t N=static_cast<size_t>(data.size());
double* d=static_cast<double*>(malloc(static_cast<size_t>(N)*sizeof(double)));
size_t rrs=0;
if (data) {

View File

@ -0,0 +1,155 @@
#include "TestWidgetBarcharts.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetBarcharts::TestWidgetBarcharts(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* barchartLayout=new QVBoxLayout(this);
setLayout(barchartLayout);
resize(1000, 800);
plotBarchart=new JKQtPlotter(true, this);
plotBarchart->set_doDrawing(false);
plotBarchart->get_plotter()->set_plotLabel(tr("\\textbf{bar charts}"));
plotBarchart->setObjectName("plotBarchart");
plotBarchart->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot_peaks/");
plotBarchart->get_plotter()->getXAxis()->set_labelType(JKQTPCALTdate);
plotBarchart->get_plotter()->getXAxis()->set_tickDateFormat("dd. MMM yyyy");
barchartLayout->addWidget(plotBarchart);
QVector<double> dataBCX, dataBCXD, dataBCY1, dataBCY2, dataBCYE1, dataBCYE2;
for (int i=0; i<8; i++) {
double x=double(i);
dataBCX<<x;
QDateTime dt;
dt.setDate(QDate(2012,1+i,1));
//qDebug()<<dt<<dt.toMSecsSinceEpoch();
dataBCXD<<double(dt.toMSecsSinceEpoch());
dataBCY1<<1.0+sin(x*M_PI/6.0);
dataBCY2<<2.0+cos(x*M_PI/3.0);
dataBCYE1<<dataBCY1.last()*0.1;
dataBCYE2<<dataBCY2.last()*0.05;
}
size_t bcpx=plotBarchart->getDatastore()->addCopiedColumn(dataBCX, "x");
size_t bcpxd=plotBarchart->getDatastore()->addCopiedColumn(dataBCXD, "x_date");
size_t bcpy1=plotBarchart->getDatastore()->addCopiedColumn(dataBCY1, "y1");
size_t bcpye1=plotBarchart->getDatastore()->addCopiedColumn(dataBCYE1, "ye1");
size_t bcpy2=plotBarchart->getDatastore()->addCopiedColumn(dataBCY2, "y2");
size_t bcpye2=plotBarchart->getDatastore()->addCopiedColumn(dataBCYE2, "ye2");
JKQTPbarHorizontalGraph* plteBar1=new JKQTPbarHorizontalGraph(plotBarchart->get_plotter());
plteBar1->set_title(tr("bars 1"));
plteBar1->set_xColumn(bcpxd);
plteBar1->set_yColumn(bcpy1);
plteBar1->set_yErrorColumn(bcpye1);
plteBar1->set_width(0.45);
plteBar1->set_shift(-0.25);
plotBarchart->get_plotter()->addGraph(plteBar1);
JKQTPbarHorizontalGraph* plteBar2=new JKQTPbarHorizontalGraph(plotBarchart->get_plotter());
plteBar2->set_xColumn(bcpxd);
plteBar2->set_yColumn(bcpy2);
plteBar2->set_yErrorColumn(bcpye2);
plteBar2->set_title(tr("bars 2"));
plteBar2->set_width(0.45);
plteBar2->set_shift(0.25);
plteBar2->set_baseline(0.5);
plteBar2->set_xErrorSymmetric(false);
plotBarchart->get_plotter()->addGraph(plteBar2);
plteBar2->autoscaleBarWidthAndShift();
plotBarchart->set_doDrawing(true);
plotBarchart->zoomToFit();
plotBarchart2=new JKQtPlotter(false, this, plotBarchart->getDatastore());
plotBarchart2->set_doDrawing(false);
plotBarchart2->get_plotter()->set_plotLabel(tr("\\textbf{bar charts}"));
plotBarchart2->setObjectName("plotBarchart2");
plotBarchart2->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot_peaks/");
barchartLayout->addWidget(plotBarchart2);
plteBar1=new JKQTPbarVerticalGraph(plotBarchart2->get_plotter());
plteBar1->set_title(tr("bars 1"));
plteBar1->set_yColumn(bcpx);
plteBar1->set_xColumn(bcpy1);
plteBar1->set_xErrorColumn(bcpye1);
plteBar1->set_width(0.45);
plteBar1->set_shift(-0.25);
plotBarchart2->get_plotter()->addGraph(plteBar1);
plteBar2=new JKQTPbarVerticalGraph(plotBarchart2->get_plotter());
plteBar2->set_yColumn(bcpx);
plteBar2->set_xColumn(bcpy2);
plteBar2->set_xErrorColumn(bcpye2);
plteBar2->set_title(tr("bars 2"));
plteBar2->set_width(0.45);
plteBar2->set_shift(0.25);
plteBar2->set_xErrorSymmetric(false);
plotBarchart2->get_plotter()->addGraph(plteBar2);
plteBar2->autoscaleBarWidthAndShift(0.9, 1);
plotBarchart2->set_doDrawing(true);
plotBarchart2->zoomToFit();
chkBarLog=new QCheckBox(tr("log-log plots"), this);
chkBarLog->setChecked(false);
barchartLayout->addWidget(chkBarLog);
connect(chkBarLog, SIGNAL(toggled(bool)), this, SLOT(setBarchartLogLog(bool)));
spinBarLabelAngel=new QSpinBox(this);
spinBarLabelAngel->setPrefix(tr("rotation angel: "));
spinBarLabelAngel->setSuffix(QLatin1String("°"));
spinBarLabelAngel->setRange(-180,180);
spinBarLabelAngel->setValue(0);
spinBarLabelAngel->setSingleStep(15);
barchartLayout->addWidget(spinBarLabelAngel);
connect(spinBarLabelAngel, SIGNAL(valueChanged(int)), this, SLOT(setBarchartAngele(int)));
spinBarLabelAngel2=new QSpinBox(this);
spinBarLabelAngel2->setPrefix(tr("rotation angel: "));
spinBarLabelAngel2->setSuffix(QLatin1String("°"));
spinBarLabelAngel2->setRange(-180,180);
spinBarLabelAngel2->setValue(0);
spinBarLabelAngel2->setSingleStep(15);
barchartLayout->addWidget(spinBarLabelAngel2);
connect(spinBarLabelAngel2, SIGNAL(valueChanged(int)), this, SLOT(setBarchartAngele2(int)));
}
void TestWidgetBarcharts::setBarchartLogLog(bool checked)
{
plotBarchart->getXAxis()->set_logAxis(checked);
plotBarchart->getYAxis()->set_logAxis(checked);
plotBarchart->zoomToFit();
plotBarchart2->getXAxis()->set_logAxis(checked);
plotBarchart2->getYAxis()->set_logAxis(checked);
plotBarchart2->zoomToFit();
}
void TestWidgetBarcharts::setBarchartAngele(int angle)
{
plotBarchart->getXAxis()->set_tickLabelAngle(angle);
plotBarchart->getXAxis()->set_drawMode2(JKQTPCADMcomplete);
}
void TestWidgetBarcharts::setBarchartAngele2(int angle)
{
plotBarchart->getYAxis()->set_tickLabelAngle(angle);
plotBarchart->getYAxis()->set_drawMode2(JKQTPCADMcomplete);
}

View File

@ -0,0 +1,59 @@
#ifndef TestWidgetBarcharts_H
#define TestWidgetBarcharts_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetBarcharts : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetBarcharts(QWidget *parent = 0);
signals:
public slots:
void setBarchartLogLog(bool checked);
void setBarchartAngele(int angel);
void setBarchartAngele2(int angel);
protected:
JKQtPlotter* plotBarchart;
JKQtPlotter* plotBarchart2;
QCheckBox* chkBarLog;
QSpinBox* spinBarLabelAngel;
QSpinBox* spinBarLabelAngel2;
};
#endif // TestWidgetBarcharts_H

View File

@ -0,0 +1,120 @@
#include "TestWidgetContourPlots.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetContourPlots::TestWidgetContourPlots(QWidget *parent) :
QWidget(parent)
{
// contour plot
QHBoxLayout* layoutContour=new QHBoxLayout(this);
setLayout(layoutContour);
JKQtPlotter* plotContour=new JKQtPlotter(true, this);
plotContour->set_doDrawing(false);
plotContour->get_plotter()->set_plotLabel(tr("\\textbf{hist contour plot}"));
plotContour->setObjectName("contour");
plotContour->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "contour/");
layoutContour->addWidget(plotContour);
JKQtPlotter* plotDensity=new JKQtPlotter(true, this);
plotContour->set_doDrawing(false);
plotContour->get_plotter()->set_plotLabel(tr("\\textbf{2D histogram plot with contours}"));
plotDensity->get_plotter()->set_plotLabel(tr("\\textbf{2D histogram}"));
plotContour->setObjectName("density");
plotContour->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "density/");
layoutContour->addWidget(plotDensity);
QVector<double> histAlex;
uint histAlexNx,histAlexNy;
// choose the test data
histAlex.clear();
histAlex.resize(5);
histAlex.append(15.0);
histAlex.append(5);
histAlex.append(0);
histAlex.append(0);
histAlex.append(5);
histAlex.append(15);
histAlex.append(6);
histAlex.append(6);
histAlex.resize(16);
histAlexNx=(uint)sqrt(histAlex.size());
histAlexNy=histAlexNx;
auto ds=plotDensity->get_plotter()->getDatastore();
plotContour->get_plotter()->useExternalDatastore(ds);
// empty datastore and grid
plotDensity->get_plotter()->clearGraphs(true);
ds->clear();
plotDensity->setGrid(false);
plotDensity->get_plotter()->getXAxis()->set_axisLabel("X");
plotDensity->get_plotter()->getYAxis()->set_axisLabel("Y");
size_t colHist2D=ds->addCopiedImageAsColumn(histAlex.data(), histAlexNx, histAlexNy, tr("2Dhist"));
// size_t colContour=plotContour->getDatastore()->addCopiedImageAsColumnTranspose(histAlex.data(), histAlexNx, histAlexNy, tr("2Dhist"));
JKQTPColumnMathImage* densityplot=new JKQTPColumnMathImage(plotDensity->get_plotter());
densityplot->set_x(-0.1);
densityplot->set_y(-0.1);
densityplot->set_width(1.1);
densityplot->set_height(1.1);
densityplot->set_Nx(histAlexNx);
densityplot->set_Ny(histAlexNy);
densityplot->set_palette(JKQTPMathImageINVERTED_OCEAN);
densityplot->set_imageColumn(colHist2D);
densityplot->set_infColor(Qt::transparent);
densityplot->set_nanColor(Qt::transparent);
densityplot->set_title("density plot");
plotDensity->addGraph(densityplot);
densityplot=new JKQTPColumnMathImage(plotContour->get_plotter());
densityplot->set_x(-0.1);
densityplot->set_y(-0.1);
densityplot->set_width(1.1);
densityplot->set_height(1.1);
densityplot->set_Nx(histAlexNx);
densityplot->set_Ny(histAlexNy);
densityplot->set_palette(JKQTPMathImageINVERTED_OCEAN);
densityplot->set_imageColumn(colHist2D);
densityplot->set_title("density plot");
plotContour->addGraph(densityplot);
plotContour->setGrid(false);
plotDensity->zoom(-0.1,1.1,-0.1,1.1);
QList<double> levels;
// levels<<5<<10<<25; // levels<<5.1<<10.1;
levels<<4<<5<<9<<14;
JKQTPContour* cp=new JKQTPContour(plotContour->get_plotter());
cp->set_x(-0.1);
cp->set_y(-0.1);
cp->set_width(1.1);
cp->set_height(1.1);
cp->set_Nx(histAlexNx);
cp->set_Ny(histAlexNy);
cp->set_imageColumn(colHist2D);
// cp->set_palette(JKQTPMathImageINVERTED_OCEAN);
cp->set_contourLevels(levels);
cp->set_title("contour plot");
plotContour->addGraph(cp);
plotContour->zoom(-0.1,1.1,-0.1,1.1);
plotContour->set_doDrawing(true);
plotContour->update_plot();
}

View File

@ -0,0 +1,47 @@
#ifndef TestWidgetContourPlots_H
#define TestWidgetContourPlots_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetContourPlots : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetContourPlots(QWidget *parent = 0);
signals:
public slots:
protected:
};
#endif // TestWidgetContourPlots_H

View File

@ -0,0 +1,33 @@
#include "TestWidgetEmptyPlot.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetEmptyPlot::TestWidgetEmptyPlot(QWidget *parent) :
QWidget(parent)
{
#define NEMPTY 500
JKQtPlotter* plotEmpty=new JKQtPlotter(true, this);
JKQTPxyLineGraph* efunc=new JKQTPxyLineGraph(plotEmpty->get_plotter());
double xef[NEMPTY], efy[NEMPTY];
for (int i=0; i<NEMPTY; i++) {
xef[i]=i;
efy[i]=double(i%5)*1e-308;
}
efunc->set_xColumn(plotEmpty->getDatastore()->addCopiedColumn(xef, NEMPTY, "x"));
efunc->set_yColumn(plotEmpty->getDatastore()->addCopiedColumn(efy, NEMPTY, "y"));
plotEmpty->addGraph(efunc);
plotEmpty->getYAxis()->set_logAxis(true);
plotEmpty->zoomToFit();
plotEmpty->setY(0,0);
}

View File

@ -0,0 +1,46 @@
#ifndef TestWidgetEmptyPlot_H
#define TestWidgetEmptyPlot_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetEmptyPlot : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetEmptyPlot(QWidget *parent = 0);
signals:
public slots:
protected:
};
#endif // TestWidgetEmptyPlot_H

View File

@ -0,0 +1,116 @@
#include "TestWidgetFunctionPlots.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetFunctionPlots::TestWidgetFunctionPlots(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* plotFuncLayout=new QVBoxLayout(this);
setLayout(plotFuncLayout);
plotFuncPlt=new JKQtPlotter(true, this);
plotFuncLayout->addWidget(plotFuncPlt);
pfunc=new JKQTPxParsedFunctionLineGraph(plotFuncPlt->get_plotter());
pfunc->set_function("x^2/10+sin(x*pi*10)");
pfunc->set_errorFunction("x^2/20");
pfunc->set_drawErrorPolygons(true);
pfunc->set_style(Qt::DashLine);
plotFuncPlt->addGraph(pfunc);
plotFuncPlt->update_plot();
pfuncErrorStyle=new JKQTPerrorPlotstyleComboBox(this);
pfuncErrorStyle->setCurrentIndex(3);
plotFuncLayout->addWidget(pfuncErrorStyle);
connect(pfuncErrorStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(setPFuncStyle()));
chkPFuncDrawSamples=new QCheckBox(tr("display samples"), this);
plotFuncLayout->addWidget(chkPFuncDrawSamples);
connect(chkPFuncDrawSamples, SIGNAL(toggled(bool)), this, SLOT(setPFuncStyle()));
chkPFuncDrawLine=new QCheckBox(tr("draw line"), this);
chkPFuncDrawLine->setChecked(true);
plotFuncLayout->addWidget(chkPFuncDrawLine);
connect(chkPFuncDrawLine, SIGNAL(toggled(bool)), this, SLOT(setPFuncStyle()));
QSpinBox* spinPFunc=new QSpinBox(this);
spinPFunc->setValue(pfunc->get_minSamples());
plotFuncLayout->addWidget(new QLabel(tr("min samples:"), this));
plotFuncLayout->addWidget(spinPFunc);
connect(spinPFunc, SIGNAL(valueChanged(int)), this, SLOT(setPFuncMinPoint(int)));
spinPFunc=new QSpinBox(this);
spinPFunc->setValue(pfunc->get_maxRefinementDegree());
plotFuncLayout->addWidget(new QLabel(tr("max refinement degree:"), this));
plotFuncLayout->addWidget(spinPFunc);
connect(spinPFunc, SIGNAL(valueChanged(int)), this, SLOT(setPFuncMaxRefine(int)));
QComboBox* edtPFunc=new QComboBox(this);
edtPFunc->addItem(pfunc->get_function());
edtPFunc->addItem("x");
edtPFunc->addItem("x^2");
edtPFunc->addItem("x^2-x^3");
edtPFunc->addItem("sin(x)");
edtPFunc->setCurrentIndex(0);
plotFuncLayout->addWidget(new QLabel(tr("function:"), this));
plotFuncLayout->addWidget(edtPFunc);
connect(edtPFunc, SIGNAL(currentIndexChanged(QString)), this, SLOT(setPFunc(QString)));
edtPFunc=new QComboBox(this);
edtPFunc->addItem(pfunc->get_errorFunction());
edtPFunc->addItem("");
edtPFunc->addItem("x");
edtPFunc->addItem("cos(x)");
edtPFunc->addItem("1");
edtPFunc->setCurrentIndex(0);
plotFuncLayout->addWidget(new QLabel(tr("error function:"), this));
plotFuncLayout->addWidget(edtPFunc);
connect(edtPFunc, SIGNAL(currentIndexChanged(QString)), this, SLOT(setPFuncE(QString)));
QCheckBox* chkFLogX=new QCheckBox(tr("x-axis: log-scale"));
chkFLogX->setChecked(false);
connect(chkFLogX, SIGNAL(toggled(bool)), plotFuncPlt->getXAxis(), SLOT(set_logAxis(bool)));
plotFuncLayout->addWidget(chkFLogX);
QCheckBox* chkFLogY=new QCheckBox(tr("y-axis: log-scale"));
chkFLogY->setChecked(false);
connect(chkFLogY, SIGNAL(toggled(bool)), plotFuncPlt->getYAxis(), SLOT(set_logAxis(bool)));
plotFuncLayout->addWidget(chkFLogY);
}
void TestWidgetFunctionPlots::setPFuncStyle()
{
pfunc->set_drawErrorLines(false);
pfunc->set_drawErrorPolygons(false);
if (pfuncErrorStyle->getErrorStyle()==JKQTPerrorLines) pfunc->set_drawErrorLines(true);
if (pfuncErrorStyle->getErrorStyle()==JKQTPerrorPolygons) pfunc->set_drawErrorPolygons(true);
pfunc->set_drawLine(chkPFuncDrawLine->isChecked());
pfunc->set_displaySamplePoints(chkPFuncDrawSamples->isChecked());
plotFuncPlt->update_plot();
}
void TestWidgetFunctionPlots::setPFuncMinPoint(int value)
{
pfunc->set_minSamples(value);
plotFuncPlt->update_plot();
}
void TestWidgetFunctionPlots::setPFuncMaxRefine(int value)
{
pfunc->set_maxRefinementDegree(value);
plotFuncPlt->update_plot();
}
void TestWidgetFunctionPlots::setPFunc(const QString &expression)
{
pfunc->set_function(expression);
plotFuncPlt->update_plot();
}
void TestWidgetFunctionPlots::setPFuncE(const QString &expression)
{
pfunc->set_errorFunction(expression);
plotFuncPlt->update_plot();
}

View File

@ -0,0 +1,58 @@
#ifndef TestWidgetFunctionPlots_H
#define TestWidgetFunctionPlots_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetFunctionPlots : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetFunctionPlots(QWidget *parent = 0);
signals:
public slots:
void setPFuncStyle();
void setPFuncMinPoint(int value);
void setPFuncMaxRefine(int value);
void setPFunc(const QString& expression);
void setPFuncE(const QString& expression);
protected:
JKQTPxParsedFunctionLineGraph* pfunc;
JKQtPlotter* plotFuncPlt;
JKQTPerrorPlotstyleComboBox* pfuncErrorStyle;
QCheckBox* chkPFuncDrawSamples;
QCheckBox* chkPFuncDrawLine;
};
#endif // TestWidgetFunctionPlots_H

View File

@ -0,0 +1,96 @@
#include "TestWidgetGeometry.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetGeometry::TestWidgetGeometry(QWidget *parent) :
QWidget(parent)
{
// create third plotter with output of a geometric drawing
QVBoxLayout* layout1=new QVBoxLayout(this);
setLayout(layout1);
resize(1000, 800);
JKQtPlotter* plotGeo=new JKQtPlotter(true, this);
plotGeo->set_doDrawing(false);
plotGeo->setObjectName("plotGeo");
layout1->addWidget(plotGeo);
plotGeo->setXY(0,1,0,1);
plotGeo->get_plotter()->getXAxis()->set_axisLabel("$x$ [mm]");
plotGeo->get_plotter()->getYAxis()->set_axisLabel("$y$ [mm]");
/*plotGeo->get_plotter()->getXAxis()->set_linkedAxis(plotGeo->get_plotter()->getYAxis());
plotGeo->get_plotter()->getXAxis()->set_changeWidthToAspectRatio(true);*/
plotGeo->get_plotter()->set_maintainAspectRatio(true);
plotGeo->get_plotter()->set_aspectRatio(1);
plotGeo->get_plotter()->set_maintainAxisAspectRatio(true);
plotGeo->get_plotter()->set_axisAspectRatio(1);
JKQTPgeoLine* line1=new JKQTPgeoLine(plotGeo->get_plotter(), -1, -2, 2, 1.5);
//plotGeo->get_plotter()->addGraph(line1);
JKQTPgeoLine* line2=new JKQTPgeoLine(plotGeo->get_plotter(), 1, -5, 4, 3, QColor("blue"), 4);
//plotGeo->get_plotter()->addGraph(line2);
JKQTPgeoRectangle* rect1=new JKQTPgeoRectangle(plotGeo->get_plotter(), 1,1,2,2, QColor("blue"),2, Qt::SolidLine, QColor("lightblue"));
rect1->set_alpha(30);
//plotGeo->get_plotter()->addGraph(rect1);
JKQTPgeoRectangle* rect2=new JKQTPgeoRectangle(plotGeo->get_plotter(), 1,1,2,2, QColor("red"),2);
rect2->set_alpha(45);
//plotGeo->get_plotter()->addGraph(rect2);
JKQTPgeoRectangle* rect3=new JKQTPgeoRectangle(plotGeo->get_plotter(), 1,1,2,4, QColor("green"),2);
rect3->set_alpha(-30);
//plotGeo->get_plotter()->addGraph(rect3);
JKQTPgeoEllipse* ell3=new JKQTPgeoEllipse(plotGeo->get_plotter(), 1,1,2,4, QColor("green"),2, Qt::SolidLine, QColor("lightgreen"), Qt::CrossPattern);
ell3->set_alpha(-30);
//plotGeo->get_plotter()->addGraph(ell3);
QVector<QPointF> p;
p.append(QPointF(4,1));
p.append(QPointF(-11,5));
p.append(QPointF(1,11));
p.append(QPointF(0,-2));
p.append(QPointF(M_PI,5.5));
JKQTPgeoPolygon* poly=new JKQTPgeoPolygon(plotGeo->get_plotter(), p, QColor("black"), 1.5, Qt::SolidLine, QColor(128,128,0,128));
//plotGeo->get_plotter()->addGraph(poly);
JKQTPgeoLines* lines=new JKQTPgeoLines(plotGeo->get_plotter(), p, QColor(255,255,0), 3);
//plotGeo->get_plotter()->addGraph(lines);
JKQTPgeoEllipse* ell1=new JKQTPgeoEllipse(plotGeo->get_plotter(), 0,0,2,4, QColor("black"),1.5, Qt::DotLine);
plotGeo->get_plotter()->addGraph(ell1);
JKQTPgeoArc* arc=new JKQTPgeoArc(plotGeo->get_plotter(), 0,0,2,4,0, 135, QColor("blue"),3, Qt::SolidLine);
//plotGeo->get_plotter()->addGraph(arc);
JKQTPgeoPie* pie=new JKQTPgeoPie(plotGeo->get_plotter(), 0,0,2,4,35, 98, QColor("blue"),3, Qt::SolidLine, QColor(0,0,255,127));
//plotGeo->get_plotter()->addGraph(pie);
JKQTPgeoChord* chord=new JKQTPgeoChord(plotGeo->get_plotter(), 0,0,2,4,35, 98, QColor("blue"),3, Qt::SolidLine, QColor(0,0,255,127));
//plotGeo->get_plotter()->addGraph(chord);
JKQTPgeoInfiniteLine* iline=new JKQTPgeoInfiniteLine(plotGeo->get_plotter(), 0.5,1,1,1, QColor("blue"), 3);
plotGeo->get_plotter()->addGraph(iline);
JKQTPgeoInfiniteLine* iline1=new JKQTPgeoInfiniteLine(plotGeo->get_plotter(), 0.5,1,-1,0, QColor("red"), 3);
plotGeo->get_plotter()->addGraph(iline1);
JKQTPgeoInfiniteLine* iline2=new JKQTPgeoInfiniteLine(plotGeo->get_plotter(), 0.5,1,0,1, QColor("red"), 3);
plotGeo->get_plotter()->addGraph(iline2);
JKQTPgeoInfiniteLine* iline3=new JKQTPgeoInfiniteLine(plotGeo->get_plotter(), 0.5,1,-1,0.5, QColor("green"), 3);
iline3->set_two_sided(true);
plotGeo->get_plotter()->addGraph(iline3);
JKQTPgeoText* text=new JKQTPgeoText(plotGeo->get_plotter(), -1, -1, "Test $f(x)=\\sqrt{\\sin(x^2)}$ \\textbf{bold}", 12, QColor("red"));
plotGeo->get_plotter()->addGraph(text);
plotGeo->set_doDrawing(true);
plotGeo->get_plotter()->zoomToFit();
plotGeo->get_plotter()->set_keyAutosize(true);
QCheckBox* chkAspect=new QCheckBox("keep aspect ratio", this);
chkAspect->setChecked(plotGeo->get_plotter()->get_maintainAxisAspectRatio());
connect(chkAspect, SIGNAL(toggled(bool)), plotGeo->get_plotter(), SLOT(set_maintainAspectRatio(bool)));
connect(chkAspect, SIGNAL(toggled(bool)), plotGeo->get_plotter(), SLOT(set_maintainAxisAspectRatio(bool)));
layout1->addWidget(chkAspect);
}

View File

@ -0,0 +1,47 @@
#ifndef TestWidgetGeometry_H
#define TestWidgetGeometry_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetGeometry : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetGeometry(QWidget *parent = 0);
signals:
public slots:
protected:
};
#endif // TestWidgetGeometry_H

View File

@ -0,0 +1,357 @@
#include "TestWidgetGraphs.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) :
QWidget(parent)
{
ovlCnt=0;
ovlTime.start();
plot=new JKQtPlotter(true, this);
plot->set_doDrawing(false);
plotBot=new JKQtPlotter(false, this, plot->getDatastore());
plotBot2=new JKQtPlotter(false, this, plot->getDatastore());
ovl1=new JKQTPoverlayVerticalLine(0.0, tr("test"), plot->get_plotter());
plot->get_plotter()->addOverlayElement(ovl1);
plot->setObjectName("plot");
plotBot->setObjectName("plotBot");
plotBot2->setObjectName("plotBot2");
plot->get_plotter()->set_plotLabel("Plot Label $1.\\alpha$");
plot->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot/");
plotBot->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot/");
plotBot2->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot/");
QListView* listPlots=new QListView(this);
listPlots->setModel(plot->get_plotter()->getPlotsModel());
listPlots->setMaximumWidth(256);
QVBoxLayout* layout=new QVBoxLayout(this);
QGridLayout* layout_grid=new QGridLayout(this);
layout_grid->addWidget(plot,0,0,1,1);
layout_grid->addWidget(plotBot,1,0,1,1);
layout_grid->addWidget(listPlots,0,1,1,1);
layout_grid->setColumnStretch(0,1);
layout->addLayout(layout_grid,2);
layout->addWidget(plotBot2,1);
setLayout(layout);
resize(1000, 800);
plotBot->synchronizeToMaster(plot, true, false);
connect(plot, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtPlotter*)), plotBot, SLOT(synchronizeXAxis(double,double,double,double,JKQtPlotter*)));
plot->get_plotter()->set_gridPrinting(true);
plot->get_plotter()->addGridPrintingPlotter(0,1,plotBot->get_plotter());
plot->get_plotter()->addGridPrintingPlotter(0,2,plotBot2->get_plotter());
plot->get_plotter()->getXAxis()->set_axisLabel("$x$ axis with greek letters $\\sqrt{\\alpha\\cdot\\beta}$");
plot->get_plotter()->getYAxis()->set_axisLabel("$y$-axis label $f(x)=\\sin\\left(x^2\\right)$ [unit]");
plotBot->get_plotter()->getXAxis()->set_axisLabel(plot->get_plotter()->getXAxis()->get_axisLabel());
plotBot->get_plotter()->getYAxis()->set_axisLabel("$y$-axis 2 [unit]");
plotBot2->get_plotter()->getXAxis()->set_axisLabel(plot->get_plotter()->getXAxis()->get_axisLabel());
plotBot2->get_plotter()->getYAxis()->set_axisLabel("$y$-axis 3 [unit]");
plotBot2->get_plotter()->getXAxis()->addAxisTickLabel(2.5, "tick 1");
plotBot2->get_plotter()->getXAxis()->addAxisTickLabel(7.5, "tick 2");
plotBot2->get_plotter()->getXAxis()->addAxisTickLabel(12.5, "tick 3");
plotBot2->get_plotter()->getXAxis()->addAxisTickLabel(17.5, "tick 4");
for (unsigned int i=0; i<N1; i++) {
x1[i]=(double)(i+1)/(double)N1*8*M_PI;
y11[i]=sin(x1[i]);
y12[i]=cos(x1[i]);
y13[i]=y12[i]/4.0;
x2r[i]=double(rand()%250)/10.0;
y21r[i]=double(rand()%100)/10.0-5.0;
y21re[i]=y21r[i]*double(rand()%10)/40.0;
}
JKQTPdatastore* ds=plot->get_plotter()->getDatastore();
//size_t cx1=ds->addColumn(x1, N1, "x1");
//size_t cy11=ds->addColumn(y11, N1, "y11");
//size_t cy12=ds->addColumn(y12, N1, "y12");
//size_t cy13=ds->addColumn(y13, N1, "y13");
//plot->addGraph(cx1, cy11, "$\\sin(x)$", JKQTPpoints);
//plot->addGraph(cy12, cx1, "$\\cos(x)$", JKQTPfilledCurveY);
//plot->addGraphWithXError(cy12, cx1, cy13, "$\\cos(x)$ with errors", JKQTPfilledCurveY, JKQTPerrorPolygons);
for (unsigned int i=0; i<N2; i++) {
x2[i]=(double)(i+1)/(double)N2*8*M_PI;
y21[i]=5*sin(x2[i]);
y22[i]=1;//1+sin(x2[i]*4);
y23[i]=pow(5,x2[i]/5.0);
y24[i]=x2[i]/10;
}
size_t cx2=ds->addColumn(x2, N2, "x2");
size_t cy21=ds->addColumn(y21, N2, "y21");
size_t cy22=ds->addColumn(y22, N2, "y22");
size_t cy23=ds->addColumn(y23, N2, "y23");
//size_t cy24=ds->addColumn(y24, N2, "y24");
size_t cx2r=ds->addColumn(x2r, N2, "x2r");
size_t cy21r=ds->addColumn(y21r, N2, "y21r");
size_t cy21re=ds->addColumn(y21re, N2, "y21re");
size_t id=plot->get_plotter()->addGraph(cx2, cy21, "$5\\cdot\\sin(x)$", JKQTPfilledCurveX);
JKQTPfilledCurveXGraph* fcxgr=qobject_cast<JKQTPfilledCurveXGraph*>(plot->get_plotter()->getGraph(id));
if (fcxgr) {
fcxgr->set_baseline(2);
}
size_t yeb=plot->get_plotter()->addGraphWithXYError(cx2, cy21, cy22, cy22, "sine with errors", JKQTPfilledCurveX);
plteErrors=plot->get_plotter()->getGraph(yeb);
setErrorStyle(0);
yeb=plot->get_plotter()->addGraph(cx2, cy21, "$5\\cdot\\sin(x)$", JKQTPlinesPoints);
plteSymbols=plot->get_plotter()->getGraph(yeb);
pltePlot2=new JKQTPxyLineErrorGraph(plotBot->get_plotter());
pltePlot2->set_xColumn(cx2r);
pltePlot2->set_yColumn(cy21r);
pltePlot2->set_title(tr("random numbers"));
pltePlot2->set_drawLine(true);
pltePlot2->set_yErrorColumn(cy21re);
pltePlot2->set_yErrorStyle(JKQTPerrorBarsPolygons);
pltePlot2->set_symbol(JKQTPfilledStar);
plotBot->get_plotter()->addGraph(pltePlot2);
plotBot->zoomToFit();
for (unsigned int i=0; i<N3; i++) {
if (i<N3/2) xbox[i]=pow(10, double(i)/N3*2.0);
else xbox[i]=10+i*2.0;
ymed[i]=i+3;
ymean[i]=i+3.5;
ymin[i]=ymed[i]-(i*2.0+1.5);
ymax[i]=ymed[i]+(i*2.0+1.5);
yp25[i]=ymed[i]-(i+0.5);
yp75[i]=ymed[i]+(i+1);
b1[i]=1.5+cos(i);
b2[i]=1.5+cos(i+M_PI/8.0);
b3[i]=1.5+sin(i);
//plot->getXAxis()->addAxisTickLabel(i+1, QString("$\\pi_{%1}\\cdot 10^{%2}$").arg(i+1).arg(i+1-N3));
//plot->getYAxis()->addAxisTickLabel(i+1, QString("$\\pi_{%1}\\cdot 10^{%2}$").arg(i+1).arg(i+1-N3));
}
size_t cbp=ds->addLinearColumn(N3, 2, N3+2, "boxplot_x");
size_t cbxbox=ds->addColumn(xbox, N3, "xbox_log");
size_t cbmean=ds->addColumn(ymean, N3, "ymean");
size_t cbmed=ds->addColumn(ymed, N3, "ymed");
size_t cbmin=ds->addColumn(ymin, N3, "ymin");
size_t cbmax=ds->addColumn(ymax, N3, "ymax");
size_t cbp25=ds->addColumn(yp25, N3, "yp25");
size_t cbp75=ds->addColumn(yp75, N3, "yp75");
QVector<size_t> cb;
cb.push_back(ds->addColumn(b1, N3, "b1"));
cb.push_back(ds->addColumn(b2, N3, "b2"));
cb.push_back(ds->addColumn(b3, N3, "b3"));
QStringList ts;
ts<<"bars 1"<<"bars 2"<<"bars 3";
plot->get_plotter()->addVerticalBargraph(cb, cbp, ts);
JKQTPverticalRange* r1=new JKQTPverticalRange(plot->get_plotter());
r1->set_rangeMin(5);
r1->set_rangeMax(10);
r1->set_rangeCenter(7.5);
r1->set_title("vert. range");
plot->get_plotter()->addGraph(r1);
JKQTPhorizontalRange* r2=new JKQTPhorizontalRange(plot->get_plotter());
r2->set_rangeMin(5);
r2->set_rangeMax(10);
r2->set_rangeCenter(7.5);
r2->set_title("hor. range");
plot->get_plotter()->addGraph(r2);
JKQTPboxplotVerticalGraph* box=new JKQTPboxplotVerticalGraph(plotBot2->get_plotter());
box->set_posColumn(cbxbox);
box->set_medianColumn(cbmed);
box->set_meanColumn(cbmean);
box->set_minColumn(cbmin);
box->set_maxColumn(cbmax);
box->set_percentile25Column(cbp25);
box->set_percentile75Column(cbp75);
box->set_title("Boxplot");
plotBot2->addGraph(box);
plotBot2->zoomToFit();
/*JKQTPyFunctionLineGraph* g=new JKQTPyFunctionLineGraph(&plot);
g->set_title("function 1");
g->set_plotFunction(f1);
g->set_errorFunction(f1e);
g->set_drawErrorLines(true);
g->set_drawErrorPolygons(false);
g->set_color(QColor("red"));
plot->addGraph(g);*/
/*JKQTPxFunctionLineGraph* g=new JKQTPxFunctionLineGraph(&plot);
g->set_title("function 2");
g->set_plotFunction(f2);
plot->addGraph(g);*/
/*JKQTPstepVerticalGraph* g=new JKQTPstepVerticalGraph(&plot);
g->set_xColumn(cy11);
g->set_yColumn(cx1);
g->set_fillCurve(true);
g->set_valuesCentered(true);
plot->addGraph(g);
plot->addGraph(cy11, cx1, "$\\sin(x)$", JKQTPpoints);*/
plot->set_doDrawing(true);
plot->get_plotter()->zoomToFit(true, false);//, true);
plot->get_plotter()->set_keyAutosize(true);
QCheckBox* chklogX=new QCheckBox("logarithmic X-axis", this);
QCheckBox* chklogY=new QCheckBox("logarithmic Y-axis", this);
connect(chklogX, SIGNAL(toggled(bool)), plot->get_plotter()->getXAxis(), SLOT(set_logAxis(bool)));
connect(chklogY, SIGNAL(toggled(bool)), plot->get_plotter()->getYAxis(), SLOT(set_logAxis(bool)));
connect(chklogX, SIGNAL(toggled(bool)), plotBot2->get_plotter()->getXAxis(), SLOT(set_logAxis(bool)));
connect(chklogY, SIGNAL(toggled(bool)), plotBot2->get_plotter()->getYAxis(), SLOT(set_logAxis(bool)));
layout->addWidget(chklogX);
layout->addWidget(chklogY);
QCheckBox* chkInvertX=new QCheckBox("invert X-axis", this);
QCheckBox* chkInvertY=new QCheckBox("invert Y-axis", this);
connect(chkInvertX, SIGNAL(toggled(bool)), plot->get_plotter()->getXAxis(), SLOT(set_inverted(bool)));
connect(chkInvertY, SIGNAL(toggled(bool)), plot->get_plotter()->getYAxis(), SLOT(set_inverted(bool)));
layout->addWidget(chkInvertX);
layout->addWidget(chkInvertY);
layout->addWidget(chkInvertX);
layout->addWidget(chkInvertY);
JKQTPSymbolComboBox* cmbPlotSymbol=new JKQTPSymbolComboBox(this);
cmbPlotSymbol->setSymbol(JKQTPplus);
connect(cmbPlotSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(setESSymbol(int)));
layout->addWidget(cmbPlotSymbol);
JKQTPerrorPlotstyleComboBox* cmbErrors=new JKQTPerrorPlotstyleComboBox(this);
cmbErrors->setCurrentErrorStyle(JKQTPerrorBars);
connect(cmbErrors, SIGNAL(currentIndexChanged(int)), this, SLOT(setErrorStyle(int)));
layout->addWidget(cmbErrors);
QDoubleSpinBox* spinScale=new QDoubleSpinBox(this);
spinScale->setRange(0.1,5);
spinScale->setSingleStep(0.1);
spinScale->setValue(1);
spinScale->setPrefix("magnification: ");
layout->addWidget(spinScale);
connect(spinScale, SIGNAL(valueChanged(double)), plot, SLOT(setMagnification(double)));
connect(spinScale, SIGNAL(valueChanged(double)), plotBot, SLOT(setMagnification(double)));
connect(spinScale, SIGNAL(valueChanged(double)), plotBot2, SLOT(setMagnification(double)));
QComboBox* cmbSortOrder2=new QComboBox(this);
cmbSortOrder2->addItem(tr("plot 2: unsorted"));
cmbSortOrder2->addItem(tr("plot 2: sort X"));
cmbSortOrder2->addItem(tr("plot 2: sort Y"));
connect(cmbSortOrder2, SIGNAL(currentIndexChanged(int)), this, SLOT(setSortOrder2(int)));
layout->addWidget(cmbSortOrder2);
JKQTPkeyLayoutComboBox* cmbKeyLayout=new JKQTPkeyLayoutComboBox(this);
connect(cmbKeyLayout, SIGNAL(currentLayoutChanged(JKQTPkeyLayout)), this, SLOT(setKeyLayout2(JKQTPkeyLayout)));
layout->addWidget(cmbKeyLayout);
JKQTPkeyPositionComboBox* cmbKeyPos=new JKQTPkeyPositionComboBox(this);
connect(cmbKeyPos, SIGNAL(currentPositionChanged(JKQTPkeyPosition)), this, SLOT(setKeyPos2(JKQTPkeyPosition)));
layout->addWidget(cmbKeyPos);
QTimer::singleShot(50, this, SLOT(moveovl()));
}
void TestWidgetGraphs::moveovl() {
ovl1->set_position(ovl1->get_position()+0.1);
if (ovl1->get_position()>30) ovl1->set_position(0);
ovlCnt++;
if (ovlCnt>20) {
double fps=double(ovlCnt)/(double(ovlTime.elapsed())/1000.0);
ovl1->set_text(QString("%1 fps").arg(fps));
ovlCnt=0;
ovlTime.start();
}
plot->update_overlays();
QTimer::singleShot(10, this, SLOT(moveovl()));
}
void TestWidgetGraphs::setErrorStyle(int index)
{
QComboBox* cmb=qobject_cast<QComboBox*>(sender());
if (cmb) {
JKQTPxyGraphErrors* exy=dynamic_cast<JKQTPxyGraphErrors*>(plteErrors);
JKQTPxGraphErrors* ex=dynamic_cast<JKQTPxGraphErrors*>(plteErrors);
JKQTPyGraphErrors* ey=dynamic_cast<JKQTPyGraphErrors*>(plteErrors);
if (exy) {
exy->set_yErrorStyle(String2JKQTPerrorPlotstyle(cmb->itemData(cmb->currentIndex()).toString()));
}
if (ey) {
ey->set_yErrorStyle(String2JKQTPerrorPlotstyle(cmb->itemData(cmb->currentIndex()).toString()));
}
plot->update_plot();
}
}
void TestWidgetGraphs::setESSymbol(int index)
{
QComboBox* cmb=qobject_cast<QComboBox*>(sender());
if (cmb) {
JKQTPxyLineGraph* exy=dynamic_cast<JKQTPxyLineGraph*>(plteSymbols);
if (exy) {
exy->set_symbol(String2JKQTPgraphSymbols(cmb->itemData(cmb->currentIndex()).toString()));
}
plot->update_plot();
}
}
void TestWidgetGraphs::setSortOrder2(int index)
{
if (index==0) pltePlot2->set_sortData(JKQTPxyLineGraph::Unsorted);
if (index==1) pltePlot2->set_sortData(JKQTPxyLineGraph::SortedX);
if (index==2) pltePlot2->set_sortData(JKQTPxyLineGraph::SortedY);
plotBot->update_plot();
}
void TestWidgetGraphs::setKeyLayout2(JKQTPkeyLayout layout)
{
plot->get_plotter()->set_keyLayout(layout);
plotBot->get_plotter()->set_keyLayout(layout);
plotBot2->get_plotter()->set_keyLayout(layout);
plot->update_plot();
plotBot->update_plot();
plotBot2->update_plot();
}
void TestWidgetGraphs::setKeyPos2(JKQTPkeyPosition layout)
{
plot->get_plotter()->set_keyPosition(layout);
plotBot->get_plotter()->set_keyPosition(layout);
plotBot2->get_plotter()->set_keyPosition(layout);
plot->update_plot();
plotBot->update_plot();
plotBot2->update_plot();
}

View File

@ -0,0 +1,74 @@
#ifndef TestWidgetGraphs_H
#define TestWidgetGraphs_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetGraphs : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetGraphs(QWidget *parent = 0);
signals:
public slots:
void moveovl();
void setErrorStyle(int index);
void setESSymbol(int index);
void setSortOrder2(int index);
void setKeyLayout2(JKQTPkeyLayout layout);
void setKeyPos2(JKQTPkeyPosition layout);
protected:
double x1[N1], x2[N2], x2r[N2]/*, x3[N3]*/;
double y11[N1], y12[N1], y13[N1], y21[N2], y21r[N2], y21re[N2], y22[N2], y23[N2], y24[N2];
double xbox[N3], ymed[N3], ymean[N3], ymin[N3], ymax[N3], yp25[N3], yp75[N3];
double b1[N3], b2[N3], b3[N3];
JKQTPoverlayVerticalLine* ovl1;
JKQtPlotter* plot;
JKQtPlotter* plotLOG;
JKQtPlotter* plotBot;
JKQtPlotter* plotBot2;
JKQTPgraph* plteErrors;
JKQTPgraph* plteSymbols;
JKQTPxyLineErrorGraph* pltePlot2;
int ovlCnt;
QElapsedTimer ovlTime;
};
#endif // TestWidgetGraphs_H

View File

@ -0,0 +1,132 @@
#include "TestWidgetImages.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetImages::TestWidgetImages(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* layouti=new QVBoxLayout(this);
QFormLayout* layWid=new QFormLayout;
layouti->addLayout(layWid);
setLayout(layouti);
resize(1000, 800);
plotImg=new JKQtPlotter(true, this);
plotImg->set_doDrawing(false);
plotImg->get_plotter()->set_plotLabel(tr("\\textbf{image plot}"));
plotImg->setObjectName("plotImg");
plotImg->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot_img/");
plotImg->get_plotter()->set_maintainAspectRatio(true);
plotImg->get_plotter()->set_aspectRatio(3.0/2.0);
plotImg->get_plotter()->set_maintainAxisAspectRatio(true);
plotImg->get_plotter()->set_axisAspectRatio(4.0);
/*plotImg->get_plotter()->getXAxis()->set_linkedAxis(plotImg->get_plotter()->getYAxis());
plotImg->get_plotter()->getXAxis()->set_changeWidthToAspectRatio(true);
plotImg->get_plotter()->getXAxis()->set_aspectRatio(1.0);*/
layouti->addWidget(plotImg);
plotImg->setXY(0,30,0,20);
plotImg->setAbsoluteXY(0,30,0,20);
img1=QImage(":/lena.png");
JKQTPImage* pimg1=new JKQTPImage(0,0,10,20, &img1, plotImg->get_plotter());
pimg1->set_title("LENA");
plotImg->get_plotter()->addGraph(pimg1);
double* img2=(double*)calloc(100*100,sizeof(double));
int32_t* img2M=(int32_t*)calloc(100*100,sizeof(int32_t));
bool* bimg2=(bool*)calloc(100*100,sizeof(bool));
for (int x=0; x<100; x++) {
for (int y=0; y<100; y++) {
img2[y*100+x]=sin(2*M_PI*sqrt(1.0+x*x+y*y)/20);
img2M[y*100+x]=abs(y-x);
bimg2[y*100+x]=static_cast<double>(rand())/static_cast<double>(RAND_MAX)>0.9;
}
}
pimg2=new JKQTPMathImage(10,0,10,10, JKQTPMathImageBase::DoubleArray, img2, 100, 100, JKQTPMathImageGRAY, plotImg->get_plotter());
pimg2->set_imageMin(-1);
pimg2->set_imageMax(0.5);
pimg2->set_imageName("left image");
pimg2->set_title("left image");
pimg2->set_autoImageRange(false);
pimg2->set_colorBarTopVisible(true);
pimg2->set_colorBarRightVisible(false);
plotImg->get_plotter()->addGraph(pimg2);
pimg3=new JKQTPMathImage(20,0,10,10, JKQTPMathImageBase::DoubleArray, img2, 100, 100, JKQTPMathImageMATLAB, plotImg->get_plotter());
pimg3->set_colorBarTopVisible(true);
pimg3->set_colorBarRightVisible(true);
pimg3->set_imageMax(0.5);
pimg3->set_rangeMaxFailAction(JKQTPMathImageGivenColor);
pimg3->set_rangeMaxFailColor(QColor("salmon"));
pimg3->set_imageMin(-0.3);
pimg3->set_rangeMinFailAction(JKQTPMathImageTransparent);
pimg3->set_autoImageRange(false);
pimg3->set_imageName("I(x,y)=\\sin\\left(\\frac{2\\pi\\cdot\\sqrt{1+x^2+y^2}}{20}\\right)");
pimg3->set_dataModifier(img2M, JKQTPMathImageBase::Int32Array);
pimg3->set_modifierMode(JKQTPMathImageBase::ModifyNone);
pimg3->set_title("right image");
plotImg->get_plotter()->addGraph(pimg3);
QColor ty=QColor("blue");
ty.setAlphaF(0.1);
JKQTPOverlayImage* oimg1=new JKQTPOverlayImage(10,0,10,10, bimg2, 100, 100, QColor("blue"), plotImg->get_plotter());
oimg1->set_title("overlay");
oimg1->set_falseColor(ty);
plotImg->get_plotter()->addGraph(oimg1);
JKQTPOverlayImageEnhanced* oimg2=new JKQTPOverlayImageEnhanced(10,0,10,10, bimg2, 100, 100, QColor("red"), plotImg->get_plotter());
oimg2->set_title("enhanced overlay");
oimg2->set_drawAsRectangles(false);
plotImg->get_plotter()->addGraph(oimg2);
plotImg->set_doDrawing(true);
plotImg->zoomToFit();
JKQTPMathImageColorPaletteComboBox* cmbPal=new JKQTPMathImageColorPaletteComboBox(this);
layWid->addRow("left image palette", cmbPal);
connect(cmbPal, SIGNAL(currentIndexChanged(int)), this, SLOT(setImgPalette1(int)));
cmbPal=new JKQTPMathImageColorPaletteComboBox(this);
layWid->addRow("right image palette", cmbPal);
connect(cmbPal, SIGNAL(currentIndexChanged(int)), this, SLOT(setImgPalette(int)));
QComboBox* cmb=new QComboBox(this);
layWid->addRow("image modifier mode", cmb);
cmb->addItem("none");
cmb->addItem("value");
cmb->addItem("lightness");
cmb->addItem("alpha");
connect(cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(setImgModifier(int)));
cmb->setCurrentIndex(1);
}
void TestWidgetImages::setImgPalette(int index)
{
pimg3->set_palette(index);
plotImg->update_plot();
}
void TestWidgetImages::setImgPalette1(int index)
{
pimg2->set_palette(index);
plotImg->update_plot();
}
void TestWidgetImages::setImgModifier(int index)
{
pimg3->set_modifierMode(JKQTPMathImage::ModifierMode(index));
plotImg->update_plot();
}

View File

@ -0,0 +1,56 @@
#ifndef TestWidgetImages_H
#define TestWidgetImages_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetImages : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetImages(QWidget *parent = 0);
signals:
public slots:
void setImgPalette(int index);
void setImgPalette1(int index);
void setImgModifier(int index);
protected:
QImage img1;
JKQTPMathImage* pimg2;
JKQTPMathImage* pimg3;
JKQtPlotter* plotImg;
};
#endif // TestWidgetImages_H

View File

@ -0,0 +1,113 @@
#include "TestWidgetLogGraphs.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
#define N2 50
TestWidgetLogGraphs::TestWidgetLogGraphs(QWidget *parent) :
QWidget(parent)
{
JKQtPlotter* plotLOG=new JKQtPlotter(this);
plotLOG->set_doDrawing(false);
plotLOG->setObjectName("plotLOG");
plotLOG->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plotLOG/");
JKQTPdatastore* ds=plotLOG->get_plotter()->getDatastore();
QVector<double> x,y;
for (unsigned int i=0; i<N2; i++) {
const double xx=static_cast<double>(i+1)/static_cast<double>(N2*8)*M_PI;
x<<xx;
y<<pow(5,xx/5.0);
}
size_t cx2=ds->addCopiedColumn(x, "x2");
size_t cy23=ds->addCopiedColumn(y, "y23");
QVBoxLayout* layout=new QVBoxLayout();
layout->addWidget(plotLOG);
QFormLayout* layWid=new QFormLayout;
layout->addLayout(layWid);
setLayout(layout);
resize(1000, 800);
plotLOG->get_plotter()->addGraph(cx2, cy23, "data, $f(x)=5^{x/5}$", JKQTPlines);
plotLOG->set_doDrawing(true);
plotLOG->get_plotter()->zoomToFit(true, true);//, true);
plotLOG->get_plotter()->set_keyAutosize(true);
QCheckBox* chklogX=new QCheckBox("logarithmic X-axis", this);
QCheckBox* chklogY=new QCheckBox("logarithmic Y-axis", this);
connect(chklogX, SIGNAL(toggled(bool)), plotLOG->get_plotter()->getXAxis(), SLOT(set_logAxis(bool)));
connect(chklogY, SIGNAL(toggled(bool)), plotLOG->get_plotter()->getYAxis(), SLOT(set_logAxis(bool)));
layWid->addWidget(chklogX);
layWid->addWidget(chklogY);
QCheckBox* chkXMinorTicks=new QCheckBox("minor X-tick labels", this);
QCheckBox* chkYMinorTicks=new QCheckBox("minor Y-tick labels", this);
connect(chkXMinorTicks, SIGNAL(toggled(bool)), plotLOG->get_plotter()->getXAxis(), SLOT(set_minorTickLabelsEnabled(bool)));
connect(chkYMinorTicks, SIGNAL(toggled(bool)), plotLOG->get_plotter()->getYAxis(), SLOT(set_minorTickLabelsEnabled(bool)));
layWid->addWidget(chkXMinorTicks);
layWid->addWidget(chkYMinorTicks);
QCheckBox* chkFullNumberMinor=new QCheckBox("full minor numbers", this);
connect(chkFullNumberMinor, SIGNAL(toggled(bool)), plotLOG->get_plotter()->getXAxis(), SLOT(set_minorTickLabelFullNumber(bool)));
connect(chkFullNumberMinor, SIGNAL(toggled(bool)), plotLOG->get_plotter()->getYAxis(), SLOT(set_minorTickLabelFullNumber(bool)));
layWid->addWidget(chkFullNumberMinor);
QComboBox* cmbTickMode=new QComboBox(this);
cmbTickMode->addItem("JKQTPLTMLinOrLog");
cmbTickMode->addItem("JKQTPLTMLin");
cmbTickMode->addItem("JKQTPLTMPower");
connect(cmbTickMode, SIGNAL(currentIndexChanged(int)), plotLOG->get_plotter()->getXAxis(), SLOT(set_tickMode(int)));
layWid->addRow("X-Axis TickMode", cmbTickMode);
cmbTickMode=new QComboBox(this);
cmbTickMode->addItem("JKQTPLTMLinOrLog");
cmbTickMode->addItem("JKQTPLTMLin");
cmbTickMode->addItem("JKQTPLTMPower");
connect(cmbTickMode, SIGNAL(currentIndexChanged(int)), plotLOG->get_plotter()->getYAxis(), SLOT(set_tickMode(int)));
layWid->addRow("Y-Axis TickMode", cmbTickMode);
cmbTickMode->setCurrentIndex(0);
plotLOG->get_plotter()->getYAxis()->set_tickMode(JKQTPLTMLinOrPower);
plotLOG->get_plotter()->getYAxis()->set_minorTicks(1);
plotLOG->get_plotter()->getYAxis()->set_drawMode2(JKQTPCADMcomplete);
plotLOG->get_plotter()->getXAxis()->set_drawMode2(JKQTPCADMcomplete);
QSpinBox* spinMinTicks=new QSpinBox(this);
spinMinTicks->setRange(0,999);
connect(spinMinTicks, SIGNAL(valueChanged(int)), plotLOG->get_plotter()->getXAxis(), SLOT(set_minorTicks(int)));
connect(spinMinTicks, SIGNAL(valueChanged(int)), plotLOG->get_plotter()->getYAxis(), SLOT(set_minorTicks(int)));
layWid->addRow("X/Y-axis minor tick count", spinMinTicks);
spinMinTicks->setValue(1);
QDoubleSpinBox* spinLOGAngle=new QDoubleSpinBox(this);
spinLOGAngle->setRange(-90,90);
spinLOGAngle->setSuffix(QLatin1String("°"));
connect(spinLOGAngle, SIGNAL(valueChanged(double)), plotLOG->get_plotter()->getXAxis(), SLOT(set_tickLabelAngle(double)));
layWid->addRow("X-Axis tick label angle", spinLOGAngle);
spinLOGAngle->setValue(0);
spinLOGAngle=new QDoubleSpinBox(this);
spinLOGAngle->setRange(-90,90);
spinLOGAngle->setSuffix(QLatin1String("°"));
connect(spinLOGAngle, SIGNAL(valueChanged(double)), plotLOG->get_plotter()->getYAxis(), SLOT(set_tickLabelAngle(double)));
layWid->addRow(tr("Y-axis label angle = "), spinLOGAngle);
spinLOGAngle->setValue(0);
}

View File

@ -0,0 +1,45 @@
#ifndef TestWidgetLogGraphs_H
#define TestWidgetLogGraphs_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
class TestWidgetLogGraphs : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetLogGraphs(QWidget *parent = 0);
signals:
public slots:
protected:
};
#endif // TestWidgetLogGraphs_H

View File

@ -0,0 +1,100 @@
#include "TestWidgetParamScatterPlots.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetParamScatterPlots::TestWidgetParamScatterPlots(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* layoutPSP=new QVBoxLayout(this);
setLayout(layoutPSP);
resize(1000, 800);
plotPSP=new JKQtPlotter(true, this);
plotPSP->set_doDrawing(false);
plotPSP->get_plotter()->set_plotLabel(tr("\\textbf{parametrized scatter plots}"));
plotPSP->setObjectName("plotPSP");
plotPSP->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot_peaks/");
layoutPSP->addWidget(plotPSP);
QVector<double> dataX, dataY, dataY1, dataY2, dataY3, dataC, dataS, dataI, dataSy ;
for (int i=0; i<100; i++) {
dataI<<i;
double x=double(i);
dataX<<x;
dataY<<sin(x*M_PI/20.0);
dataY1<<3.0+sin(x*M_PI/20.0);
dataY2<<dataY1.last()/5.0;
dataY3<<dataY1.last()+4.0;
dataC<<x;
dataS<<(sin(x*M_PI/30.0)+1.0)*50.0;
dataSy<<(2+i%15);
}
int pspx=plotPSP->getDatastore()->addCopiedColumn(dataX, "x");
int pspy=plotPSP->getDatastore()->addCopiedColumn(dataY, "y");
int pspy1=plotPSP->getDatastore()->addCopiedColumn(dataY1, "y1");
int pspy2=plotPSP->getDatastore()->addCopiedColumn(dataY2, "y2");
int pspy3=plotPSP->getDatastore()->addCopiedColumn(dataY2, "y3");
int pspc=plotPSP->getDatastore()->addCopiedColumn(dataC, "color");
int psps=plotPSP->getDatastore()->addCopiedColumn(dataS, "size");
int pspsy=plotPSP->getDatastore()->addCopiedColumn(dataSy, "symbol");
pltePSPCol=new JKQTPxyParametrizedErrorScatterGraph(plotPSP->get_plotter());
pltePSPCol->set_title(tr("changing color"));
pltePSPCol->set_xColumn(pspx);
pltePSPCol->set_yColumn(pspy);
pltePSPCol->set_colorColumn(pspc);
pltePSPCol->set_yErrorColumn(pspy1);
pltePSPCol->set_yErrorColumnLower(pspy2);
pltePSPCol->set_yErrorSymmetric(true);
pltePSPCol->set_drawLine(true);
plotPSP->get_plotter()->addGraph(pltePSPCol);
pltePSPSize=new JKQTPxyParametrizedScatterGraph(plotPSP->get_plotter());
pltePSPSize->set_xColumn(pspx);
pltePSPSize->set_yColumn(pspy1);
pltePSPSize->set_sizeColumn(psps);
pltePSPSize->set_title(tr("changing size"));
plotPSP->get_plotter()->addGraph(pltePSPSize);
pltePSPSymb=new JKQTPxyParametrizedScatterGraph(plotPSP->get_plotter());
pltePSPSymb->set_xColumn(pspx);
pltePSPSymb->set_yColumn(pspy3);
pltePSPSymb->set_symbolColumn(pspsy);
pltePSPSymb->set_title(tr("changing symbol"));
plotPSP->get_plotter()->addGraph(pltePSPSymb);
plotPSP->set_doDrawing(true);
plotPSP->zoomToFit();
QCheckBox* chkPSPErrorSymmetric=new QCheckBox(tr("symmetric errors"), this);
chkPSPErrorSymmetric->setChecked(true);
connect(chkPSPErrorSymmetric, SIGNAL(toggled(bool)), this, SLOT(setPSPSymmErrors(bool)));
layoutPSP->addWidget(chkPSPErrorSymmetric);
}
void TestWidgetParamScatterPlots::setPSPSymmErrors(bool checked)
{
pltePSPCol->set_yErrorSymmetric(checked);
plotPSP->update_plot();
}

View File

@ -0,0 +1,53 @@
#ifndef TestWidgetParamScatterPlots_H
#define TestWidgetParamScatterPlots_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetParamScatterPlots : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetParamScatterPlots(QWidget *parent = 0);
signals:
public slots:
void setPSPSymmErrors(bool checked);
protected:
JKQtPlotter* plotPSP;
JKQTPxyParametrizedErrorScatterGraph* pltePSPCol;
JKQTPxyParametrizedScatterGraph* pltePSPSize;
JKQTPxyParametrizedScatterGraph* pltePSPSymb;
};
#endif // TestWidgetParamScatterPlots_H

View File

@ -0,0 +1,76 @@
#include "TestWidgetPeaksPlots.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetPeaksPlots::TestWidgetPeaksPlots(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* layoutpeaks=new QVBoxLayout(this);
setLayout(layoutpeaks);
resize(1000, 800);
plotPeaks=new JKQtPlotter(true, this);
plotPeaks->set_doDrawing(false);
plotPeaks->get_plotter()->set_plotLabel(tr("\\textbf{peaks stream plot}"));
plotPeaks->setObjectName("plotPeaks");
plotPeaks->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot_peaks/");
QCheckBox* chkDrawBaseline=new QCheckBox(tr("draw baseline"), this);
chkDrawBaseline->setChecked(true);
connect(chkDrawBaseline, SIGNAL(toggled(bool)), this, SLOT(setDrawBaseline(bool)));
layoutpeaks->addWidget(chkDrawBaseline);
QCheckBox* chkYPeaks=new QCheckBox(tr("y peaks"), this);
chkYPeaks->setChecked(true);
connect(chkYPeaks, SIGNAL(toggled(bool)), this, SLOT(setYPeaks(bool)));
layoutpeaks->addWidget(chkYPeaks);
layoutpeaks->addWidget(plotPeaks);
QVector<double> photons1, photons2;
for (int i=0; i<1000; i++) {
double x=double(i)/1000.0;
const double p=0.33*fabs(sin(x*4.0*M_PI))*fabs(sin(x*4.0*M_PI));
if (static_cast<double>(rand())/static_cast<double>(RAND_MAX)<=p) photons1<<x;
if (static_cast<double>(rand())/static_cast<double>(RAND_MAX)<=p) photons2<<x;
}
int phot1=plotPeaks->getDatastore()->addCopiedColumn(photons1, "photons 1");
int phot2=plotPeaks->getDatastore()->addCopiedColumn(photons2, "photons 2");
graphPeakStream1=new JKQTPPeakStreamGraph(phot1, 0.05, 1, QColor("darkgreen"), plotPeaks->get_plotter());
graphPeakStream1->set_title("channel 1");
plotPeaks->get_plotter()->addGraph(graphPeakStream1);
graphPeakStream2=new JKQTPPeakStreamGraph(phot2, -0.05, -1, QColor("darkred"), plotPeaks->get_plotter());
graphPeakStream2->set_title("channel 2");
plotPeaks->get_plotter()->addGraph(graphPeakStream2);
plotPeaks->set_doDrawing(true);
plotPeaks->zoomToFit();
}
void TestWidgetPeaksPlots::setDrawBaseline(bool checked)
{
graphPeakStream1->set_drawBaseline(checked);
graphPeakStream2->set_drawBaseline(checked);
plotPeaks->update_plot();
}
void TestWidgetPeaksPlots::setYPeaks(bool checked)
{
graphPeakStream1->set_yPeaks(checked);
graphPeakStream2->set_yPeaks(checked);
plotPeaks->update_plot();
}

View File

@ -0,0 +1,51 @@
#ifndef TestWidgetPeaksPlots_H
#define TestWidgetPeaksPlots_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetPeaksPlots : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetPeaksPlots(QWidget *parent = 0);
signals:
public slots:
void setDrawBaseline(bool checked);
void setYPeaks(bool checked);
protected:
JKQtPlotter* plotPeaks;
JKQTPPeakStreamGraph* graphPeakStream1;
JKQTPPeakStreamGraph* graphPeakStream2;
};
#endif // TestWidgetPeaksPlots_H

View File

@ -0,0 +1,203 @@
#include "TestWidgetRGBImages.h"
#include <QDebug>
#include <QDate>
#include <QDateTime>
#include <QApplication>
TestWidgetRGBImages::TestWidgetRGBImages(QWidget *parent) :
QWidget(parent)
{
// plotter for images
QWidget* winrgb=new QWidget(this);
QVBoxLayout* layoutrgb=new QVBoxLayout(this);
QFormLayout* frm=new QFormLayout(nullptr);
winrgb->setLayout(layoutrgb);
winrgb->resize(1000, 800);
plotImgRGB=new JKQtPlotter(true, winrgb);
plotImgRGB->set_doDrawing(false);
plotImgRGB->get_plotter()->set_plotLabel(tr("\\textbf{RGB image plot}"));
plotImgRGB->setObjectName("plotImgRGB");
plotImgRGB->get_plotter()->set_userSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plot_img_rgb/");
/*plotImgRGB->get_plotter()->set_maintainAspectRatio(true);
plotImgRGB->get_plotter()->set_aspectRatio(1.0);
plotImgRGB->get_plotter()->set_maintainAxisAspectRatio(true);
plotImgRGB->get_plotter()->set_axisAspectRatio(1.0);*/
QCheckBox* chkColorbars=new QCheckBox(tr("color bars share space"), winrgb);
chkColorbars->setChecked(true);
connect(chkColorbars, SIGNAL(toggled(bool)), this, SLOT(setRGBColorBars(bool)));
layoutrgb->addWidget(chkColorbars);
layoutrgb->addLayout(frm);
layoutrgb->addWidget(plotImgRGB);
plotImgRGB->setXY(0,100,0,100);
plotImgRGB->setAbsoluteXY(0,100,0,100);
rgb_rimg2=(double*)calloc(100*100,sizeof(double));
rgb_bimg2=(double*)calloc(100*100,sizeof(double));
rgb_gimg2=(double*)calloc(100*100,sizeof(double));
rgb_aimg2=(double*)calloc(100*100,sizeof(double));
for (int x=0; x<100; x++) {
for (int y=0; y<100; y++) {
rgb_rimg2[y*100+x]=sin(2*M_PI*sqrt(1.0+x*x+y*y)/20);
rgb_bimg2[y*100+x]=sin(2*M_PI*sqrt(1.0+x*x+y*y)/30);
rgb_gimg2[y*100+x]=cos(2*M_PI*sqrt(1.0+x*x+y*y)/30);
rgb_aimg2[y*100+x]=double(x)/100.0;
}
}
rgbimg=new JKQTPRGBMathImage(0,0,10,10, JKQTPMathImageBase::DoubleArray, rgb_rimg2, 100, 100, plotImgRGB->get_plotter());
rgbimg->set_imageMin(-1);
rgbimg->set_imageMax(0.5);
rgbimg->set_imageMinB(-1);
rgbimg->set_imageMaxB(0.5);
rgbimg->set_imageName("R image");
rgbimg->set_imageNameG("G image");
rgbimg->set_imageNameB("B image");
rgbimg->set_data(rgb_rimg2, rgb_gimg2, rgb_bimg2, 100, 100, JKQTPMathImageBase::DoubleArray);
rgbimg->set_dataModifier(rgb_aimg2, JKQTPMathImageBase::DoubleArray);
rgbimg->set_modifierMode(JKQTPMathImageBase::ModifyNone);
plotImgRGB->get_plotter()->addGraph(rgbimg);
rgbimg->set_autoImageRange(false);
rgbimg->set_colorBarTopVisible(true);
rgbimg->set_colorBarRightVisible(true);
rgbimg->set_colorbarsSideBySide(chkColorbars->isChecked());
rgbimg2=new JKQTPColumnRGBMathImage(10,0,10,10,100,100, plotImgRGB->get_plotter());
rgbimg2->set_imageMin(-1);
rgbimg2->set_imageMax(0.5);
rgbimg2->set_imageMinB(-1);
rgbimg2->set_imageMaxB(0.5);
rgbimg2->set_imageName("R image");
rgbimg2->set_imageNameG("G image");
rgbimg2->set_imageNameB("B image");
rgbimg2->set_Nx(100);
rgbimg2->set_Ny(100);
rgbimg2->set_imageRColumn(rgb_colr=plotImgRGB->getDatastore()->addCopiedColumn(rgb_bimg2, 100*100, "R"));
rgbimg2->set_imageGColumn(rgb_colg=plotImgRGB->getDatastore()->addCopiedColumn(rgb_gimg2, 100*100, "G"));
rgbimg2->set_imageBColumn(rgb_colb=plotImgRGB->getDatastore()->addCopiedColumn(rgb_rimg2, 100*100, "B"));
rgbimg2->set_modifierColumn(rgb_cola=plotImgRGB->getDatastore()->addCopiedColumn(rgb_aimg2, 100*100, "alpha"));
rgbimg2->set_modifierMode(JKQTPMathImageBase::ModifyNone);
//rgbimg2->set_data(rgb_rimg2, rgb_gimg2, rgb_bimg2, 100, 100, JKQTPMathImageBase::DoubleArray);
plotImgRGB->get_plotter()->addGraph(rgbimg2);
rgbimg2->set_autoImageRange(true);
rgbimg2->set_colorBarTopVisible(true);
rgbimg2->set_colorBarRightVisible(true);
rgbimg2->set_colorbarsSideBySide(chkColorbars->isChecked());
plotImgRGB->setAbsoluteXY(0,20,0,10);
plotImgRGB->set_doDrawing(true);
//plotImgRGB->zoomToFit();
plotImgRGB->setXY(0,20,0,10);
QComboBox* cmb=new QComboBox(winrgb);
frm->addRow(tr("mode 1:"), cmb);
cmb->addItem("RGB");
cmb->addItem("HSV");
cmb->addItem("HSL");
cmb->addItem("CMY");
cmb->setCurrentIndex(0);
connect(cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(setRGBMode1(int)));
cmb=new QComboBox(winrgb);
frm->addRow(tr("mode 2:"), cmb);
cmb->addItem("RGB");
cmb->addItem("HSV");
cmb->addItem("HSL");
cmb->addItem("CMY");
connect(cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(setRGBMode2(int)));
cmb->setCurrentIndex(1);
cmb=new QComboBox(winrgb);
frm->addRow(tr("modifier channel mode:"), cmb);
cmb->addItem("none");
cmb->addItem("value");
cmb->addItem("lightness");
cmb->addItem("alpha");
connect(cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(setRGBModifier(int)));
cmb->setCurrentIndex(0);
QHBoxLayout* hblrgb=new QHBoxLayout();
frm->addRow(tr("use channels:"), hblrgb);
chkRGBUseR=new QCheckBox(tr("red"), winrgb);
hblrgb->addWidget(chkRGBUseR);
chkRGBUseR->setChecked(true);
connect(chkRGBUseR, SIGNAL(toggled(bool)), this, SLOT(updateRGBChannels()));
chkRGBUseG=new QCheckBox(tr("green"), winrgb);
hblrgb->addWidget(chkRGBUseG);
chkRGBUseG->setChecked(true);
connect(chkRGBUseG, SIGNAL(toggled(bool)), this, SLOT(updateRGBChannels()));
chkRGBUseB=new QCheckBox(tr("blue"), winrgb);
hblrgb->addWidget(chkRGBUseB);
chkRGBUseB->setChecked(true);
connect(chkRGBUseB, SIGNAL(toggled(bool)), this, SLOT(updateRGBChannels()));
chkRGBUseA=new QCheckBox(tr("alpha"), winrgb);
hblrgb->addWidget(chkRGBUseA);
chkRGBUseB->setChecked(false);
connect(chkRGBUseB, SIGNAL(toggled(bool)), this, SLOT(updateRGBChannels()));
}
void TestWidgetRGBImages::setRGBColorBars(bool checked)
{
rgbimg->set_colorbarsSideBySide(checked);
rgbimg2->set_colorbarsSideBySide(checked);
plotImgRGB->update_plot();
}
void TestWidgetRGBImages::setRGBMode1(int mode)
{
rgbimg->set_rgbMode((JKQTPRGBMathImageRGBMode)mode);
plotImgRGB->update_plot();
}
void TestWidgetRGBImages::setRGBMode2(int mode)
{
rgbimg2->set_rgbMode((JKQTPRGBMathImageRGBMode)mode);
plotImgRGB->update_plot();
}
void TestWidgetRGBImages::updateRGBChannels()
{
if (chkRGBUseR->isChecked()) {
rgbimg->set_data(rgb_rimg2, 100, 100);
rgbimg2->set_imageRColumn(rgb_colr);
} else {
rgbimg->set_data(nullptr, 100, 100);
rgbimg2->set_imageRColumn(-1);
}
if (chkRGBUseG->isChecked()) {
rgbimg->set_dataG(rgb_gimg2);
rgbimg2->set_imageGColumn(rgb_colg);
} else {
rgbimg->set_dataG(nullptr);
rgbimg2->set_imageGColumn(-1);
}
if (chkRGBUseB->isChecked()) {
rgbimg->set_dataB(rgb_bimg2);
rgbimg2->set_imageBColumn(rgb_colb);
} else {
rgbimg->set_dataB(nullptr);
rgbimg2->set_imageBColumn(-1);
}
plotImgRGB->update_plot();
}
void TestWidgetRGBImages::setRGBModifier(int item)
{
rgbimg->set_modifierMode(JKQTPMathImage::ModifierMode(item));
rgbimg2->set_modifierMode(JKQTPMathImage::ModifierMode(item));
plotImgRGB->update_plot();
}

View File

@ -0,0 +1,69 @@
#ifndef TestWidgetRGBImages_H
#define TestWidgetRGBImages_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
#define N3 8
class TestWidgetRGBImages : public QWidget
{
Q_OBJECT
public:
explicit TestWidgetRGBImages(QWidget *parent = 0);
signals:
public slots:
void setRGBColorBars(bool checked);
void setRGBMode1(int mode);
void setRGBMode2(int mode);
void updateRGBChannels();
void setRGBModifier(int item);
protected:
double* rgb_rimg2;
double* rgb_gimg2;
double* rgb_bimg2;
double* rgb_aimg2;
int rgb_colr, rgb_colb, rgb_colg, rgb_cola;
JKQtPlotter* plotImgRGB;
JKQTPRGBMathImage* rgbimg;
JKQTPColumnRGBMathImage* rgbimg2;
QCheckBox* chkRGBUseR;
QCheckBox* chkRGBUseG;
QCheckBox* chkRGBUseB;
QCheckBox* chkRGBUseA;
};
#endif // TestWidgetRGBImages_H

View File

@ -7,6 +7,17 @@ include(../../jkqtplotter.pri)
SOURCES += jkqtplot_test.cpp \
testmain.cpp \
TestWidgetFunctionPlots.cpp \
TestWidgetGeometry.cpp \
TestWidgetGraphs.cpp \
TestWidgetImages.cpp \
TestWidgetLogGraphs.cpp \
TestWidgetParamScatterPlots.cpp \
TestWidgetPeaksPlots.cpp \
TestWidgetRGBImages.cpp \
TestWidgetBarcharts.cpp \
TestWidgetContourPlots.cpp \
TestWidgetEmptyPlot.cpp \
QTeXEngine/src/QTeXPaintEngine.cpp \
QTeXEngine/src/QTeXPaintDevice.cpp
@ -15,14 +26,14 @@ greaterThan(QT_MAJOR_VERSION, 4) {
win32 {
SOURCES += jkqtpemfengineadapter.cpp \
EmfEngine/src/EmfPaintDevice.cpp \
EmfEngine/src/EmfEngine.cpp
EmfEngine/src/EmfEngine.cpp \
HEADERS +=EmfEngine/src/EmfEngine.h \
jkqtpemfengineadapter.h
}
}
CONFIG += qt console
CONFIG += qt
#QMAKE_LFLAGS += -s
@ -44,7 +55,19 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
#if not added by qmake:
DEFINES += QT_XML_LIB
HEADERS += testmain.h
HEADERS += testmain.h \
TestWidgetFunctionPlots.h \
TestWidgetGeometry.h \
TestWidgetGraphs.h \
TestWidgetImages.h \
TestWidgetLogGraphs.h \
TestWidgetParamScatterPlots.h \
TestWidgetPeaksPlots.h \
TestWidgetRGBImages.h \
TestWidgetBarcharts.h \
TestWidgetContourPlots.h \
TestWidgetEmptyPlot.h \
QTeXEngine/src/QTeXEngine.h
INCLUDEPATH +=

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,7 @@
#ifndef TESTMAIN_H
#define TESTMAIN_H
#include <QElapsedTimer>
#include <QCheckBox>
#include <QLineEdit>
#include <QTimer>
#include <QImage>
#include <QVBoxLayout>
#include <QWidget>
#include <QTabWidget>
#include <QFormLayout>
#include <QCheckBox>
#include "../../jkqtplotter.h"
#include "../../jkqtpgeoelements.h"
#include "../../jkqtpimageelements.h"
#include "../../jkqtpoverlayelements.h"
#include "../../jkqtpparsedfunctionelements.h"
#include "../../jkqtpbaseelements.h"
#include "../../jkqtpplotsmodel.h"
#include "../../jkqtptools.h"
#define N1 200
#define N2 50
@ -35,97 +19,9 @@ class TestMain : public QTabWidget
signals:
public slots:
void moveovl();
void setRGBColorBars(bool checked);
void setDrawBaseline(bool checked);
void setYPeaks(bool checked);
void setPFuncStyle();
void setPFuncMinPoint(int value);
void setPFuncMaxRefine(int value);
void setPFunc(const QString& expression);
void setPFuncE(const QString& expression);
void setRGBMode1(int mode);
void setRGBMode2(int mode);
void updateRGBChannels();
void setRGBModifier(int item);
void setImgPalette(int index);
void setImgPalette1(int index);
void setImgModifier(int index);
void setErrorStyle(int index);
void setESSymbol(int index);
void setBarchartLogLog(bool checked);
void setBarchartAngele(int angel);
void setBarchartAngele2(int angel);
void setPSPSymmErrors(bool checked);
void setSortOrder2(int index);
void setKeyLayout2(JKQTPkeyLayout layout);
void setKeyPos2(JKQTPkeyPosition layout);
protected:
double x1[N1], x2[N2], x2r[N2]/*, x3[N3]*/;
double y11[N1], y12[N1], y13[N1], y21[N2], y21r[N2], y21re[N2], y22[N2], y23[N2], y24[N2];
double xbox[N3], ymed[N3], ymean[N3], ymin[N3], ymax[N3], yp25[N3], yp75[N3];
double b1[N3], b2[N3], b3[N3];
QImage img1;
double* rgb_rimg2;
double* rgb_gimg2;
double* rgb_bimg2;
double* rgb_aimg2;
int rgb_colr, rgb_colb, rgb_colg, rgb_cola;
JKQTPoverlayVerticalLine* ovl1;
JKQtPlotter* plot;
JKQtPlotter* plotLOG;
JKQtPlotter* plotBot;
JKQtPlotter* plotBot2;
JKQtPlotter* plotImgRGB;
JKQtPlotter* plotPeaks;
JKQTPRGBMathImage* rgbimg;
JKQTPColumnRGBMathImage* rgbimg2;
JKQTPgraph* plteErrors;
JKQTPgraph* plteSymbols;
JKQTPxyLineErrorGraph* pltePlot2;
JKQTPPeakStreamGraph* graphPeakStream1;
JKQTPPeakStreamGraph* graphPeakStream2;
JKQTPxParsedFunctionLineGraph* pfunc;
JKQtPlotter* plotFuncPlt;
JKQTPerrorPlotstyleComboBox* pfuncErrorStyle;
QCheckBox* chkPFuncDrawSamples;
QCheckBox* chkPFuncDrawLine;
QCheckBox* chkRGBUseR;
QCheckBox* chkRGBUseG;
QCheckBox* chkRGBUseB;
QCheckBox* chkRGBUseA;
JKQTPMathImage* pimg2;
JKQTPMathImage* pimg3;
JKQtPlotter* plotImg;
JKQtPlotter* plotPSP;
JKQTPxyParametrizedErrorScatterGraph* pltePSPCol;
JKQTPxyParametrizedScatterGraph* pltePSPSize;
JKQTPxyParametrizedScatterGraph* pltePSPSymb;
JKQtPlotter* plotBarchart;
JKQtPlotter* plotBarchart2;
QCheckBox* chkBarLog;
QSpinBox* spinBarLabelAngel;
QSpinBox* spinBarLabelAngel2;
int ovlCnt;
QElapsedTimer ovlTime;
};