mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 09:31:40 +08:00
restructured files in this lib further (splt into more files, made filenames more logical, ...)
This commit is contained in:
parent
743a1865bd
commit
1737c83d42
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center (DKFZ) & IWR, University of Heidelberg
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>) (DKFZ) & IWR, University of Heidelberg
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center (DKFZ) & IWR, University of Heidelberg
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>) (DKFZ) & IWR, University of Heidelberg
|
||||
|
||||
|
||||
|
||||
|
@ -12,51 +12,65 @@
|
||||
|
||||
HEADERS += $$PWD/jkqtplotter/jkqtpbaseplotter.h \
|
||||
$$PWD/jkqtplotter/jkqtpdatastorage.h \
|
||||
$$PWD/jkqtplotter/jkqtpbasegraphs.h \
|
||||
$$PWD/jkqtplotter/jkqtpelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsbase.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphs.h \
|
||||
$$PWD/jkqtplotter/jkqtpbaseelements.h \
|
||||
$$PWD/jkqtplotter/jkqtplotter.h \
|
||||
$$PWD/jkqtplottertools/jkqtptools.h \
|
||||
$$PWD/jkqtplottertools/jkqttools.h \
|
||||
$$PWD/jkqtplotter/jkqtpimageelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpimagetools.h \
|
||||
$$PWD/jkqtplotter/jkqtpbarchartelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpboxplotelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpevaluatedfunctionelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpfilledcurveelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpimpulseselements.h \
|
||||
$$PWD/jkqtplotter/jkqtpparsedfunctionelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpoverlayelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpgeoelements.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsimage.h \
|
||||
$$PWD/jkqtplottertools/jkqtpimagetools.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsbarchart.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsboxplot.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsvaluatedfunction.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsfilledcurve.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsimpulses.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsparsedfunction.h \
|
||||
$$PWD/jkqtplotter/jkqtpelementsoverlay.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsgeometric.h \
|
||||
$$PWD/jkqtplotter/jkqtpgraphspeakstream.h \
|
||||
$$PWD/jkqtplottertools/jkqtpmathparser.h \
|
||||
$$PWD/jkqtplottertools/jkqtp_imexport.h \
|
||||
$$PWD/jkqtplotter/jkqtpplotsmodel.h \
|
||||
$$PWD/jkqtplottergui/jkqtpgraphsmodel.h \
|
||||
$$PWD/jkqtplottergui/jkqtpcomboboxes.h \
|
||||
$$PWD/jkqtplottergui/jkqtpenhancedtableview.h \
|
||||
$$PWD/jkqtplottergui/jkqtpenhancedspinboxes.h \
|
||||
$$PWD/jkqtplottergui/jkvanishqtoolbar.h \
|
||||
$$PWD/jkqtmathtext/jkqtmathtext.h \
|
||||
$$PWD/jkqtplottertools/jkqtphighrestimer.h
|
||||
$$PWD/jkqtplottertools/jkqtpdrawingtools.h \
|
||||
$$PWD/jkqtplottertools/jkqtphighrestimer.h \
|
||||
$$PWD/jkqtplottertools/jkqtpenhancedpainter.h
|
||||
|
||||
|
||||
SOURCES += $$PWD/jkqtplotter/jkqtpbaseplotter.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpdatastorage.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpbasegraphs.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsbase.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphs.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpbaseelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtplotter.cpp \
|
||||
$$PWD/jkqtplottertools/jkqtptools.cpp \
|
||||
$$PWD/jkqtplottertools/jkqttools.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpimageelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpimagetools.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpbarchartelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpboxplotelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpevaluatedfunctionelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpfilledcurveelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpimpulseselements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpparsedfunctionelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpoverlayelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgeoelements.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsimage.cpp \
|
||||
$$PWD/jkqtplottertools/jkqtpimagetools.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsbarchart.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsboxplot.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsvaluatedfunction.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsfilledcurve.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsimpulses.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsparsedfunction.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpelementsoverlay.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphsgeometric.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpgraphspeakstream.cpp \
|
||||
$$PWD/jkqtplottertools/jkqtpmathparser.cpp \
|
||||
$$PWD/jkqtplotter/jkqtpplotsmodel.cpp \
|
||||
$$PWD/jkqtplottergui/jkqtpgraphsmodel.cpp \
|
||||
$$PWD/jkqtplottergui/jkqtpcomboboxes.cpp \
|
||||
$$PWD/jkqtplottergui/jkqtpenhancedtableview.cpp \
|
||||
$$PWD/jkqtplottergui/jkqtpenhancedspinboxes.cpp \
|
||||
$$PWD/jkqtplottergui/jkvanishqtoolbar.cpp \
|
||||
$$PWD/jkqtmathtext/jkqtmathtext.cpp \
|
||||
$$PWD/jkqtplottertools/jkqtphighrestimer.cpp
|
||||
$$PWD/jkqtplottertools/jkqtpdrawingtools.cpp \
|
||||
$$PWD/jkqtplottertools/jkqtphighrestimer.cpp \
|
||||
$$PWD/jkqtplottertools/jkqtpenhancedpainter.cpp
|
||||
|
||||
|
||||
RESOURCES += $$PWD/jkqtplotterressources/jkqtpbaseplotter.qrc
|
||||
|
@ -27,7 +27,7 @@
|
||||
* These classes are used by JKQtPlotterBase to output the plot
|
||||
*/
|
||||
|
||||
/** \file jkqtpelements.h
|
||||
/** \file jkqtpgraphs.h
|
||||
* \ingroup jkqtpbaseplotter_elements
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
@ -35,7 +35,8 @@
|
||||
#include <QPrintPreviewWidget>
|
||||
#include <QDialog>
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpenhancedtableview.h"
|
||||
#include <QPrinter>
|
||||
#include <QPrinterInfo>
|
||||
#include <QPrintDialog>
|
||||
@ -49,10 +50,10 @@
|
||||
#ifdef QFWIDLIB_LIBRARY
|
||||
# include "qftools.h"
|
||||
#endif
|
||||
#include "jkqtplotter/jkqtpboxplotelements.h"
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpfilledcurveelements.h"
|
||||
#include "jkqtplotter/jkqtpimpulseselements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsboxplot.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
#include "jkqtplotter/jkqtpgraphsfilledcurve.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimpulses.h"
|
||||
|
||||
static QString globalUserSettigsFilename="";
|
||||
static QString globalUserSettigsPrefix="";
|
||||
@ -194,7 +195,7 @@ JKQtBasePlotter::JKQtBasePlotter(bool datastore_internal, QObject* parent, JKQTP
|
||||
|
||||
xAxis=new JKQTPhorizontalAxis(this);
|
||||
yAxis=new JKQTPverticalAxis(this);
|
||||
m_plotsModel=new JKQTPPlotsModel(this);
|
||||
m_plotsModel=new JKQTPgraphsModel(this);
|
||||
connect(this, SIGNAL(plotUpdated()), m_plotsModel, SLOT(plotUpdated()));
|
||||
|
||||
|
||||
|
@ -36,11 +36,12 @@
|
||||
#include "jkqtplotter/jkqtpdatastorage.h"
|
||||
#include "jkqtmathtext/jkqtmathtext.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplottertools/jkqtpenhancedpainter.h"
|
||||
#include "jkqtplottergui/jkqtpenhancedspinboxes.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QAction>
|
||||
@ -68,7 +69,7 @@
|
||||
#define JKQTPBASEPLOTTER_H
|
||||
|
||||
|
||||
class JKQTPPlotsModel; // forward
|
||||
class JKQTPgraphsModel; // forward
|
||||
|
||||
/** \brief initialized Qt-ressources necessary for JKQtBasePlotter */
|
||||
LIB_EXPORT void initJKQtBasePlotterResources();
|
||||
@ -206,7 +207,7 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
JKQTmathText mathText;
|
||||
|
||||
/** \brief model representing all Plots in this plotter and showing their visible/invisible state */
|
||||
JKQTPPlotsModel* m_plotsModel;
|
||||
JKQTPgraphsModel* m_plotsModel;
|
||||
|
||||
/** \brief object used for the x-axis */
|
||||
JKQTPhorizontalAxis* xAxis;
|
||||
@ -767,7 +768,7 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
||||
inline JKQTPdatastore* getDatastore() { return datastore; }
|
||||
|
||||
/** \brief returns model representing all Plots in this plotter and showing their visible/invisible state */
|
||||
inline JKQTPPlotsModel* getPlotsModel() { return m_plotsModel; }
|
||||
inline JKQTPgraphsModel* getPlotsModel() { return m_plotsModel; }
|
||||
|
||||
/** \brief tells the plotter object to use the given external datastore.
|
||||
*
|
||||
|
@ -664,7 +664,13 @@ class LIB_EXPORT JKQTPcolumn {
|
||||
* column.
|
||||
*/
|
||||
inline double getValue(size_t n) const;
|
||||
/** \brief gets a pointer to the n-th value in the column
|
||||
/** \brief reads the \a n'th value from the column
|
||||
*
|
||||
* This method accesses the datastore and returns the double value stored in the \a n'th row of the according
|
||||
* column.
|
||||
*/
|
||||
inline double getValue(int n) const;
|
||||
/** \brief gets a pointer to the n-th value in the column
|
||||
*/
|
||||
double* getPointer(size_t n=0) const ;
|
||||
|
||||
@ -872,6 +878,14 @@ inline double JKQTPcolumn::getValue(size_t n) const {
|
||||
return datastore->getItem(datastoreItem)->get(datastoreOffset, n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
inline double JKQTPcolumn::getValue(int n) const {
|
||||
if (!datastore) return 0;
|
||||
if (!datastore->getItem(datastoreItem)) return 0;
|
||||
if (n<0) return 0;
|
||||
return datastore->getItem(datastoreItem)->get(datastoreOffset, static_cast<size_t>(n));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
inline double JKQTPdatastore::get(size_t column, size_t row) const {
|
||||
return columns[column].getValue(row);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include <stdlib.h>
|
@ -24,7 +24,7 @@
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
/** \file jkqtpoverlayelements.h
|
||||
/** \file jkqtpelementsoverlay.h
|
||||
* \ingroup jkqtplotter_overlays
|
||||
*/
|
||||
|
||||
@ -35,8 +35,8 @@
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
|
||||
#ifndef JKQTPOVERLAYELEMENTS_H
|
||||
#define JKQTPOVERLAYELEMENTS_H
|
||||
#ifndef jkqtpelementsoverlay_H
|
||||
#define jkqtpelementsoverlay_H
|
||||
|
||||
// forward declarations
|
||||
class JKQtBasePlotter;
|
||||
@ -246,4 +246,4 @@ class LIB_EXPORT JKQTPoverlayRectangle : public JKQTPoverlayTwoPositionOverlay {
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif // JKQTPOVERLAYELEMENTS_H
|
||||
#endif // jkqtpelementsoverlay_H
|
@ -19,14 +19,14 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
||||
@ -39,192 +39,6 @@
|
||||
|
||||
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(JKQtBasePlotter *parent):
|
||||
JKQTPsingleColumnGraph(parent)
|
||||
{
|
||||
baseline=0;
|
||||
yPeaks=true;
|
||||
peakHeight=1;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtBasePlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, color, Qt::SolidLine, 2.0, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtBasePlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(JKQtPlotter *parent):
|
||||
JKQTPsingleColumnGraph(parent)
|
||||
{
|
||||
baseline=0;
|
||||
yPeaks=true;
|
||||
peakHeight=1;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtPlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, color, Qt::SolidLine, 2.0, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtPlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
bool JKQTPPeakStreamGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
|
||||
{
|
||||
if (yPeaks) {
|
||||
return getDataMinMax(dataColumn, minx, maxx, smallestGreaterZero);
|
||||
} else {
|
||||
minx=qMin(baseline, baseline+peakHeight);
|
||||
maxx=qMax(baseline, baseline+peakHeight);
|
||||
return true;
|
||||
//smallestGreaterZero=qMax(double(0.0), qMin(baseline, baseline+peakHeight));
|
||||
}
|
||||
}
|
||||
|
||||
bool JKQTPPeakStreamGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
|
||||
{
|
||||
if (!yPeaks) {
|
||||
return getDataMinMax(dataColumn, miny, maxy, smallestGreaterZero);
|
||||
} else {
|
||||
miny=qMin(baseline, baseline+peakHeight);
|
||||
maxy=qMax(baseline, baseline+peakHeight);
|
||||
return true;
|
||||
//smallestGreaterZero=qMax(double(0.0), qMin(baseline, baseline+peakHeight));
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter)
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTPPeakStreamGraph::draw");
|
||||
#endif
|
||||
if (parent==nullptr) return;
|
||||
JKQTPdatastore* datastore=parent->getDatastore();
|
||||
if (datastore==nullptr) return;
|
||||
if (dataColumn<0) return;
|
||||
|
||||
drawErrorsBefore(painter);
|
||||
|
||||
painter.save();
|
||||
|
||||
QPen p=getLinePen(painter);
|
||||
p.setCapStyle(Qt::FlatCap);
|
||||
|
||||
int imax=static_cast<int>(datastore->getColumn(static_cast<size_t>(dataColumn)).getRows());
|
||||
int imin=0;
|
||||
// interpret data ranges
|
||||
if (datarange_start>-1) {
|
||||
imin=qMin(datarange_start, static_cast<int>(imax));
|
||||
}
|
||||
if (datarange_end>-1) {
|
||||
imax=qMin(datarange_end, static_cast<int>(imax));
|
||||
}
|
||||
if (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
QVector<QLineF> lines;
|
||||
|
||||
if (yPeaks) {
|
||||
if (drawBaseline) {
|
||||
lines<<QLineF(transform(parent->getXMin(), baseline), transform(parent->getXMax(), baseline));
|
||||
}
|
||||
intSortData();
|
||||
for (int iii=imin; iii<imax; iii++) {
|
||||
int i=qBound<int>(imin, getDataIndex(static_cast<int>(iii)), imax);
|
||||
const double xv=datastore->get(dataColumn,i);
|
||||
if (JKQTPIsOKFloat(xv)) {
|
||||
lines<<QLineF(transform(xv, baseline), transform(xv, baseline+peakHeight));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (drawBaseline) {
|
||||
lines<<QLineF(transform(baseline, parent->getYMin()), transform(baseline, parent->getYMax()));
|
||||
}
|
||||
intSortData();
|
||||
for (int iii=imin; iii<imax; iii++) {
|
||||
int i=qBound<int>(imin, getDataIndex(iii), imax);
|
||||
const double yv=datastore->get(dataColumn,i);
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
lines<<QLineF(transform(baseline, yv), transform(baseline+peakHeight, yv));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
painter.setPen(p);
|
||||
if (lines.size()>0) painter.drawLines(lines);
|
||||
|
||||
|
||||
painter.restore();
|
||||
|
||||
drawErrorsAfter(painter);
|
||||
}
|
||||
|
||||
void JKQTPPeakStreamGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
|
||||
{
|
||||
painter.save();
|
||||
QPen p=getLinePen(painter);
|
||||
painter.setPen(p);
|
||||
if (yPeaks) {
|
||||
p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.width()/10.0)));
|
||||
if (drawBaseline) {
|
||||
if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
else painter.drawLine(rect.topLeft(), rect.topRight());
|
||||
}
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.1, rect.top()),QPointF( rect.left()+rect.width()*0.1, rect.bottom()));
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.55, rect.top()), QPointF(rect.left()+rect.width()*0.55, rect.bottom()));
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.75, rect.top()), QPointF(rect.left()+rect.width()*0.75, rect.bottom()));
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.9, rect.top()), QPointF(rect.left()+rect.width()*0.9, rect.bottom()));
|
||||
} else {
|
||||
p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.height()/15.0)));
|
||||
if (drawBaseline) {
|
||||
if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.topLeft());
|
||||
else painter.drawLine(rect.bottomRight(), rect.topRight());
|
||||
}
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.1), QPointF(rect.right(), rect.top()+rect.height()*0.1));
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.55), QPointF(rect.right(), rect.top()+rect.height()*0.55));
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.75), QPointF(rect.right(), rect.top()+rect.height()*0.75));
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.9), QPointF(rect.right(), rect.top()+rect.height()*0.9));
|
||||
}
|
||||
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPxyLineGraph::JKQTPxyLineGraph(JKQtPlotter* parent):
|
@ -26,7 +26,7 @@
|
||||
* \ingroup jkqtplotter_elements
|
||||
*/
|
||||
|
||||
/** \file jkqtpelements.h
|
||||
/** \file jkqtpgraphs.h
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
@ -35,11 +35,12 @@
|
||||
#include <QPair>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplotter/jkqtpbasegraphs.h"
|
||||
#include "jkqtplottertools/jkqtpdrawingtools.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbase.h"
|
||||
#include "jkqtplottertools/jkqtpenhancedpainter.h"
|
||||
|
||||
#ifndef JKQTPELEMENTS_H
|
||||
#define JKQTPELEMENTS_H
|
||||
#ifndef jkqtpgraphs_H
|
||||
#define jkqtpgraphs_H
|
||||
|
||||
// forward declarations
|
||||
class JKQtBasePlotter;
|
||||
@ -49,62 +50,6 @@ class JKQTPdatastore;
|
||||
//class JKQTPColorPaletteTools;
|
||||
|
||||
|
||||
/*! \brief interprets data as a stream of x- or y-positions \f$ p_i \f$ (depending in \a yPeaks ) ans plots a line on the height
|
||||
\a baseline and upright lines from baseline to baseline+peakHeight at each position \f$ p_i \f$. This can be used to
|
||||
display a stream of photons with given arrivaltimes \f$ p_i \f$.
|
||||
\ingroup jkqtplotter_plots
|
||||
|
||||
\image html JKQTPPeakStreamGraphY.png "yPeaks=true"
|
||||
\image html JKQTPPeakStreamGraphX.png "yPeaks=false"
|
||||
*/
|
||||
class LIB_EXPORT JKQTPPeakStreamGraph: public JKQTPsingleColumnGraph {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
JKQTPPeakStreamGraph(JKQtBasePlotter* parent=nullptr);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtBasePlotter* parent=nullptr);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtBasePlotter* parent=nullptr);
|
||||
JKQTPPeakStreamGraph(JKQtPlotter* parent);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtPlotter* parent);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtPlotter* parent);
|
||||
|
||||
/** \brief get the maximum and minimum x-value of the graph
|
||||
*
|
||||
* The result is given in the two parameters which are call-by-reference parameters!
|
||||
*/
|
||||
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero);
|
||||
/** \brief get the maximum and minimum y-value of the graph
|
||||
*
|
||||
* The result is given in the two parameters which are call-by-reference parameters!
|
||||
*/
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero);
|
||||
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter);
|
||||
/** \brief plots a key marker inside the specified rectangle \a rect */
|
||||
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect);
|
||||
|
||||
JKQTPGET_SET_MACRO(double, baseline)
|
||||
JKQTPGET_SET_MACRO(double, peakHeight)
|
||||
JKQTPGET_SET_MACRO(bool, yPeaks)
|
||||
JKQTPGET_SET_MACRO(bool, drawBaseline)
|
||||
|
||||
protected:
|
||||
|
||||
/** \brief position of the baseline */
|
||||
double baseline;
|
||||
/** \brief height of each peak */
|
||||
double peakHeight;
|
||||
/** \brief if set \c true the peaks are in Y direction (default: true)*/
|
||||
bool yPeaks;
|
||||
/** \brief indicates whether to draw the basleine (default: \c true ) */
|
||||
bool drawBaseline;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -605,4 +550,4 @@ class LIB_EXPORT JKQTPverticalRange: public JKQTPhorizontalRange {
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero);
|
||||
};
|
||||
|
||||
#endif // JKQTPELEMENTS_H
|
||||
#endif // jkqtpgraphs_H
|
@ -19,13 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
* \ingroup jkqtplotter_elements
|
||||
*/
|
||||
|
||||
/** \file jkqtpelements.h
|
||||
/** \file jkqtpgraphs.h
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
@ -35,11 +35,11 @@
|
||||
#include <QPair>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplotter/jkqtpbasegraphs.h"
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbase.h"
|
||||
|
||||
#ifndef JKQTPBARCHARTELEMENTS_H
|
||||
#define JKQTPBARCHARTELEMENTS_H
|
||||
#ifndef jkqtpgraphsbarchart_H
|
||||
#define jkqtpgraphsbarchart_H
|
||||
|
||||
|
||||
|
||||
@ -359,4 +359,4 @@ class LIB_EXPORT JKQTPbarHorizontalErrorGraph: public JKQTPbarHorizontalGraph, p
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPBARCHARTELEMENTS_H
|
||||
#endif // jkqtpgraphsbarchart_H
|
@ -19,13 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpbasegraphs.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbase.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
@ -26,7 +26,7 @@
|
||||
* \ingroup jkqtplotter_elements
|
||||
*/
|
||||
|
||||
/** \file jkqtpelements.h
|
||||
/** \file jkqtpgraphs.h
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
@ -35,10 +35,10 @@
|
||||
#include <QPair>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
|
||||
#ifndef JKQTPBASEGRAPHS_H
|
||||
#define JKQTPBASEGRAPHS_H
|
||||
#ifndef jkqtpgraphsbase_H
|
||||
#define jkqtpgraphsbase_H
|
||||
|
||||
// forward declarations
|
||||
class JKQtBasePlotter;
|
||||
@ -557,4 +557,4 @@ class LIB_EXPORT JKQTPxyGraphErrors: public JKQTPgraphErrors {
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPBASEGRAPHS_H
|
||||
#endif // jkqtpgraphsbase_H
|
@ -19,13 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpboxplotelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsboxplot.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
@ -26,7 +26,7 @@
|
||||
* \ingroup jkqtplotter_elements
|
||||
*/
|
||||
|
||||
/** \file jkqtpelements.h
|
||||
/** \file jkqtpgraphs.h
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
@ -35,11 +35,11 @@
|
||||
#include <QPair>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplotter/jkqtpbasegraphs.h"
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbase.h"
|
||||
|
||||
#ifndef JKQTPBOXPLOTELEMENTS_H
|
||||
#define JKQTPBOXPLOTELEMENTS_H
|
||||
#ifndef jkqtpgraphsboxplot_H
|
||||
#define jkqtpgraphsboxplot_H
|
||||
|
||||
|
||||
|
||||
@ -368,4 +368,4 @@ class LIB_EXPORT JKQTPboxplotHorizontalElement: public JKQTPboxplotVerticalEleme
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPBOXPLOTELEMENTS_H
|
||||
#endif // jkqtpgraphsboxplot_H
|
@ -19,13 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpfilledcurveelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsfilledcurve.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
@ -19,10 +19,10 @@
|
||||
|
||||
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpbasegraphs.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbase.h"
|
||||
|
||||
#ifndef JKQTPFILLEDCURVEELEMENTS_H
|
||||
#define JKQTPFILLEDCURVEELEMENTS_H
|
||||
#ifndef jkqtpgraphsfilledcurve_H
|
||||
#define jkqtpgraphsfilledcurve_H
|
||||
|
||||
|
||||
|
||||
@ -237,4 +237,4 @@ class LIB_EXPORT JKQTPfilledVerticalRangeGraph: public JKQTPxyGraph {
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPFILLEDCURVEELEMENTS_H
|
||||
#endif // jkqtpgraphsfilledcurve_H
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
@ -26,20 +26,20 @@
|
||||
|
||||
*/
|
||||
|
||||
/** \file jkqtpgeoelements.h
|
||||
/** \file jkqtpgraphsgeometric.h
|
||||
* \ingroup jkqtplotter_geoplots
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
#include <QPair>
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtmathtext/jkqtmathtext.h"
|
||||
|
||||
#ifndef JKQTPGEOELEMENTS_H_INCLUDED
|
||||
#define JKQTPGEOELEMENTS_H_INCLUDED
|
||||
#ifndef jkqtpgraphsgeometric_H_INCLUDED
|
||||
#define jkqtpgraphsgeometric_H_INCLUDED
|
||||
|
||||
|
||||
/*! \brief This virtual JKQTPgraph descendent may be used as base class for geometric drawing
|
||||
@ -744,4 +744,4 @@ class LIB_EXPORT JKQTPgeoChord: public JKQTPgeoPie {
|
||||
};
|
||||
|
||||
|
||||
#endif // JKQTPGEOELEMENTS_H_INCLUDED
|
||||
#endif // jkqtpgraphsgeometric_H_INCLUDED
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger & Sebastian Isbaner (contour plot), German Cancer Research Center
|
||||
Copyright (c) 2008-2018 Jan W. Krieger & Sebastian Isbaner (contour plot)
|
||||
|
||||
|
||||
|
||||
@ -18,10 +18,11 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtpenhancedpainter.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include <QDebug>
|
||||
#include <QImageWriter>
|
||||
@ -30,9 +31,6 @@
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
#define PALETTE_ICON_WIDTH 64
|
||||
#define PALETTE_IMAGEICON_HEIGHT 64
|
||||
|
||||
|
||||
JKQTPImageBase::JKQTPImageBase(double x, double y, double width, double height, JKQtBasePlotter* parent):
|
||||
JKQTPgraph(parent)
|
||||
@ -1133,9 +1131,9 @@ int JKQTPMathImage::getPalettesCount()
|
||||
}
|
||||
|
||||
QIcon JKQTPMathImage::getPaletteIcon(int i) {
|
||||
QImage img=getPaletteImage(i, PALETTE_ICON_WIDTH);
|
||||
QPixmap pix(PALETTE_ICON_WIDTH,8);
|
||||
QRect r(0,0,PALETTE_ICON_WIDTH-1,7);
|
||||
QImage img=getPaletteImage(i, JKQTP_PALETTE_ICON_WIDTH);
|
||||
QPixmap pix(JKQTP_PALETTE_ICON_WIDTH,8);
|
||||
QRect r(0,0,JKQTP_PALETTE_ICON_WIDTH-1,7);
|
||||
JKQTPEnhancedPainter p(&pix);
|
||||
p.drawImage(r, img);
|
||||
p.setPen(QPen(QColor("black")));
|
||||
@ -1168,9 +1166,9 @@ QImage JKQTPMathImage::getPaletteImage(JKQTPMathImageColorPalette palette, int w
|
||||
|
||||
QIcon JKQTPMathImage::getPaletteKeyIcon(int i)
|
||||
{
|
||||
QImage img=getPaletteKeyImage(i, PALETTE_ICON_WIDTH, PALETTE_IMAGEICON_HEIGHT);
|
||||
QPixmap pix(PALETTE_ICON_WIDTH,PALETTE_IMAGEICON_HEIGHT);
|
||||
QRect r(0,0,PALETTE_ICON_WIDTH-1,PALETTE_IMAGEICON_HEIGHT-1);
|
||||
QImage img=getPaletteKeyImage(i, JKQTP_PALETTE_ICON_WIDTH, JKQTP_PALETTE_IMAGEICON_HEIGHT);
|
||||
QPixmap pix(JKQTP_PALETTE_ICON_WIDTH,JKQTP_PALETTE_IMAGEICON_HEIGHT);
|
||||
QRect r(0,0,JKQTP_PALETTE_ICON_WIDTH-1,JKQTP_PALETTE_IMAGEICON_HEIGHT-1);
|
||||
JKQTPEnhancedPainter p(&pix);
|
||||
p.drawImage(r, img);
|
||||
p.setPen(QPen(QColor("black")));
|
||||
@ -2506,33 +2504,6 @@ void JKQTPColumnRGBMathImage::ensureImageData()
|
||||
this->dataModifier=parent->getDatastore()->getColumn(modifierColumn).getPointer(0);
|
||||
}
|
||||
|
||||
JKQTPImageModifierModeComboBox::JKQTPImageModifierModeComboBox(QWidget * /*parent*/)
|
||||
{
|
||||
addMode(JKQTPMathImageBase::ModifyNone, tr("none"));
|
||||
addMode(JKQTPMathImageBase::ModifyValue, tr("value"));
|
||||
addMode(JKQTPMathImageBase::ModifySaturation, tr("saturation"));
|
||||
addMode(JKQTPMathImageBase::ModifyAlpha, tr("alpha"));
|
||||
}
|
||||
|
||||
JKQTPMathImageBase::ModifierMode JKQTPImageModifierModeComboBox::getModifierMode() const
|
||||
{
|
||||
bool ok=false;
|
||||
JKQTPMathImageBase::ModifierMode m=JKQTPMathImageBase::ModifyNone;
|
||||
if (currentIndex()>=0) m=JKQTPMathImageBase::ModifierMode(itemData(currentIndex()).toInt(&ok));
|
||||
if (!ok) m=JKQTPMathImageBase::ModifyNone;
|
||||
return m;
|
||||
}
|
||||
|
||||
void JKQTPImageModifierModeComboBox::setModifierMode(JKQTPMathImageBase::ModifierMode mode)
|
||||
{
|
||||
setCurrentIndex(findData((int)mode));
|
||||
}
|
||||
|
||||
void JKQTPImageModifierModeComboBox::addMode(JKQTPMathImageBase::ModifierMode mode, const QString &name, const QIcon &icon)
|
||||
{
|
||||
addItem(icon, name, (int)mode);
|
||||
}
|
||||
|
||||
|
||||
QVector<double> JKQTPRGBMathImage::getDataGAsDoubleVector() const
|
||||
{
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger & Sebastian Isbaner (contour plot), German Cancer Research Center
|
||||
Copyright (c) 2008-2018 Jan W. Krieger & Sebastian Isbaner (contour plot)
|
||||
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JKQTPIMAGEELEMENTS_H
|
||||
#define JKQTPIMAGEELEMENTS_H
|
||||
#ifndef jkqtpgraphsimage_H
|
||||
#define jkqtpgraphsimage_H
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
*/
|
||||
|
||||
/** \file jkqtpimageelements.h
|
||||
/** \file jkqtpgraphsimage.h
|
||||
* \ingroup jkqtplotter_imagelots
|
||||
*/
|
||||
|
||||
@ -38,11 +38,11 @@
|
||||
#include <QPainter>
|
||||
#include <QImage>
|
||||
#include <QIcon>
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
|
||||
|
||||
|
||||
@ -214,20 +214,6 @@ class LIB_EXPORT JKQTPMathImageBase: public JKQTPImageBase {
|
||||
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPMathImageBase::ModifierMode
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPImageModifierModeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPImageModifierModeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPMathImageBase::ModifierMode getModifierMode() const;
|
||||
void setModifierMode(JKQTPMathImageBase::ModifierMode mode);
|
||||
protected:
|
||||
void addMode(JKQTPMathImageBase::ModifierMode mode, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
/*! \brief class to plot an image from a QImage object
|
||||
\ingroup jkqtplotter_imagelots
|
||||
|
||||
@ -990,5 +976,5 @@ private:
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPIMAGEELEMENTS_H
|
||||
#endif // jkqtpgraphsimage_H
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpimpulseselements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimpulses.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
@ -18,11 +18,11 @@
|
||||
*/
|
||||
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpbasegraphs.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbase.h"
|
||||
|
||||
|
||||
#ifndef JKQTPIMPULSESELEMENTS_H
|
||||
#define JKQTPIMPULSESELEMENTS_H
|
||||
#ifndef jkqtpgraphsimpulses_H
|
||||
#define jkqtpgraphsimpulses_H
|
||||
|
||||
|
||||
|
||||
@ -133,4 +133,4 @@ class LIB_EXPORT JKQTPimpulsesVerticalErrorGraph: public JKQTPimpulsesVerticalGr
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPIMPULSESELEMENTS_H
|
||||
#endif // jkqtpgraphsimpulses_H
|
@ -19,8 +19,8 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include <stdlib.h>
|
@ -18,8 +18,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JKQTPPARSEDFUNCTIONELEMENTS_H
|
||||
#define JKQTPPARSEDFUNCTIONELEMENTS_H
|
||||
#ifndef jkqtpgraphsparsedfunction_H
|
||||
#define jkqtpgraphsparsedfunction_H
|
||||
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
@ -27,7 +27,7 @@
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtpmathparser.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplotter/jkqtpevaluatedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsvaluatedfunction.h"
|
||||
|
||||
// forward declarations
|
||||
class JKQtBasePlotter;
|
||||
@ -90,4 +90,4 @@ class LIB_EXPORT JKQTPxParsedFunctionLineGraph: public JKQTPxFunctionLineGraph {
|
||||
/** \brief fill the data array with data from the function plotFunction */
|
||||
virtual void createPlotData(bool collectParams=true);
|
||||
};
|
||||
#endif // JKQTPPARSEDFUNCTIONELEMENTS_H
|
||||
#endif // jkqtpgraphsparsedfunction_H
|
219
lib/jkqtplotter/jkqtpgraphspeakstream.cpp
Normal file
219
lib/jkqtplotter/jkqtpgraphspeakstream.cpp
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/jkqtpgraphspeakstream.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(JKQtBasePlotter *parent):
|
||||
JKQTPsingleColumnGraph(parent)
|
||||
{
|
||||
baseline=0;
|
||||
yPeaks=true;
|
||||
peakHeight=1;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtBasePlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, color, Qt::SolidLine, 2.0, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtBasePlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(JKQtPlotter *parent):
|
||||
JKQTPsingleColumnGraph(parent)
|
||||
{
|
||||
baseline=0;
|
||||
yPeaks=true;
|
||||
peakHeight=1;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtPlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, color, Qt::SolidLine, 2.0, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
JKQTPPeakStreamGraph::JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtPlotter *parent):
|
||||
JKQTPsingleColumnGraph(dataColumn, parent)
|
||||
{
|
||||
yPeaks=true;
|
||||
this->baseline=baseline;
|
||||
this->peakHeight=peakHeight;
|
||||
drawBaseline=true;
|
||||
}
|
||||
|
||||
bool JKQTPPeakStreamGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
|
||||
{
|
||||
if (yPeaks) {
|
||||
return getDataMinMax(dataColumn, minx, maxx, smallestGreaterZero);
|
||||
} else {
|
||||
minx=qMin(baseline, baseline+peakHeight);
|
||||
maxx=qMax(baseline, baseline+peakHeight);
|
||||
return true;
|
||||
//smallestGreaterZero=qMax(double(0.0), qMin(baseline, baseline+peakHeight));
|
||||
}
|
||||
}
|
||||
|
||||
bool JKQTPPeakStreamGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
|
||||
{
|
||||
if (!yPeaks) {
|
||||
return getDataMinMax(dataColumn, miny, maxy, smallestGreaterZero);
|
||||
} else {
|
||||
miny=qMin(baseline, baseline+peakHeight);
|
||||
maxy=qMax(baseline, baseline+peakHeight);
|
||||
return true;
|
||||
//smallestGreaterZero=qMax(double(0.0), qMin(baseline, baseline+peakHeight));
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter)
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTPPeakStreamGraph::draw");
|
||||
#endif
|
||||
if (parent==nullptr) return;
|
||||
JKQTPdatastore* datastore=parent->getDatastore();
|
||||
if (datastore==nullptr) return;
|
||||
if (dataColumn<0) return;
|
||||
|
||||
drawErrorsBefore(painter);
|
||||
|
||||
painter.save();
|
||||
|
||||
QPen p=getLinePen(painter);
|
||||
p.setCapStyle(Qt::FlatCap);
|
||||
|
||||
int imax=static_cast<int>(datastore->getColumn(static_cast<size_t>(dataColumn)).getRows());
|
||||
int imin=0;
|
||||
// interpret data ranges
|
||||
if (datarange_start>-1) {
|
||||
imin=qMin(datarange_start, static_cast<int>(imax));
|
||||
}
|
||||
if (datarange_end>-1) {
|
||||
imax=qMin(datarange_end, static_cast<int>(imax));
|
||||
}
|
||||
if (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
QVector<QLineF> lines;
|
||||
|
||||
if (yPeaks) {
|
||||
if (drawBaseline) {
|
||||
lines<<QLineF(transform(parent->getXMin(), baseline), transform(parent->getXMax(), baseline));
|
||||
}
|
||||
intSortData();
|
||||
for (int iii=imin; iii<imax; iii++) {
|
||||
int i=qBound<int>(imin, getDataIndex(static_cast<int>(iii)), imax);
|
||||
const double xv=datastore->get(dataColumn,i);
|
||||
if (JKQTPIsOKFloat(xv)) {
|
||||
lines<<QLineF(transform(xv, baseline), transform(xv, baseline+peakHeight));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (drawBaseline) {
|
||||
lines<<QLineF(transform(baseline, parent->getYMin()), transform(baseline, parent->getYMax()));
|
||||
}
|
||||
intSortData();
|
||||
for (int iii=imin; iii<imax; iii++) {
|
||||
int i=qBound<int>(imin, getDataIndex(iii), imax);
|
||||
const double yv=datastore->get(dataColumn,i);
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
lines<<QLineF(transform(baseline, yv), transform(baseline+peakHeight, yv));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
painter.setPen(p);
|
||||
if (lines.size()>0) painter.drawLines(lines);
|
||||
|
||||
|
||||
painter.restore();
|
||||
|
||||
drawErrorsAfter(painter);
|
||||
}
|
||||
|
||||
void JKQTPPeakStreamGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
|
||||
{
|
||||
painter.save();
|
||||
QPen p=getLinePen(painter);
|
||||
painter.setPen(p);
|
||||
if (yPeaks) {
|
||||
p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.width()/10.0)));
|
||||
if (drawBaseline) {
|
||||
if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
else painter.drawLine(rect.topLeft(), rect.topRight());
|
||||
}
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.1, rect.top()),QPointF( rect.left()+rect.width()*0.1, rect.bottom()));
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.55, rect.top()), QPointF(rect.left()+rect.width()*0.55, rect.bottom()));
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.75, rect.top()), QPointF(rect.left()+rect.width()*0.75, rect.bottom()));
|
||||
painter.drawLine(QPointF(rect.left()+rect.width()*0.9, rect.top()), QPointF(rect.left()+rect.width()*0.9, rect.bottom()));
|
||||
} else {
|
||||
p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH,qMin(parent->pt2px(painter, p.widthF()), rect.height()/15.0)));
|
||||
if (drawBaseline) {
|
||||
if (peakHeight>=0) painter.drawLine(rect.bottomLeft(), rect.topLeft());
|
||||
else painter.drawLine(rect.bottomRight(), rect.topRight());
|
||||
}
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.1), QPointF(rect.right(), rect.top()+rect.height()*0.1));
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.55), QPointF(rect.right(), rect.top()+rect.height()*0.55));
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.75), QPointF(rect.right(), rect.top()+rect.height()*0.75));
|
||||
painter.drawLine(QPointF(rect.left(), rect.top()+rect.height()*0.9), QPointF(rect.right(), rect.top()+rect.height()*0.9));
|
||||
}
|
||||
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
105
lib/jkqtplotter/jkqtpgraphspeakstream.h
Normal file
105
lib/jkqtplotter/jkqtpgraphspeakstream.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtplotter_elements Plot Elements
|
||||
* \ingroup jkqtplotter
|
||||
* \defgroup jkqtplotter_plots Graphs
|
||||
* \ingroup jkqtplotter_elements
|
||||
*/
|
||||
|
||||
/** \file jkqtpgraphs.h
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
#include <QPair>
|
||||
#include "jkqtplotter/jkqtpgraphsbase.h"
|
||||
|
||||
#ifndef jkqtpgraphspeakstream_H_INCLUDED
|
||||
#define jkqtpgraphspeakstream_H_INCLUDED
|
||||
|
||||
// forward declarations
|
||||
class JKQtBasePlotter;
|
||||
class JKQtPlotter;
|
||||
class JKQTPcoordinateAxis;
|
||||
class JKQTPdatastore;
|
||||
|
||||
|
||||
/*! \brief interprets data as a stream of x- or y-positions \f$ p_i \f$ (depending in \a yPeaks ) ans plots a line on the height
|
||||
\a baseline and upright lines from baseline to baseline+peakHeight at each position \f$ p_i \f$. This can be used to
|
||||
display a stream of photons with given arrivaltimes \f$ p_i \f$.
|
||||
\ingroup jkqtplotter_plots
|
||||
|
||||
\image html JKQTPPeakStreamGraphY.png "yPeaks=true"
|
||||
\image html JKQTPPeakStreamGraphX.png "yPeaks=false"
|
||||
*/
|
||||
class LIB_EXPORT JKQTPPeakStreamGraph: public JKQTPsingleColumnGraph {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
JKQTPPeakStreamGraph(JKQtBasePlotter* parent=nullptr);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtBasePlotter* parent=nullptr);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtBasePlotter* parent=nullptr);
|
||||
JKQTPPeakStreamGraph(JKQtPlotter* parent);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, QColor color, JKQtPlotter* parent);
|
||||
JKQTPPeakStreamGraph(int dataColumn, double baseline, double peakHeight, JKQtPlotter* parent);
|
||||
|
||||
/** \brief get the maximum and minimum x-value of the graph
|
||||
*
|
||||
* The result is given in the two parameters which are call-by-reference parameters!
|
||||
*/
|
||||
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero);
|
||||
/** \brief get the maximum and minimum y-value of the graph
|
||||
*
|
||||
* The result is given in the two parameters which are call-by-reference parameters!
|
||||
*/
|
||||
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero);
|
||||
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter);
|
||||
/** \brief plots a key marker inside the specified rectangle \a rect */
|
||||
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect);
|
||||
|
||||
JKQTPGET_SET_MACRO(double, baseline)
|
||||
JKQTPGET_SET_MACRO(double, peakHeight)
|
||||
JKQTPGET_SET_MACRO(bool, yPeaks)
|
||||
JKQTPGET_SET_MACRO(bool, drawBaseline)
|
||||
|
||||
protected:
|
||||
|
||||
/** \brief position of the baseline */
|
||||
double baseline;
|
||||
/** \brief height of each peak */
|
||||
double peakHeight;
|
||||
/** \brief if set \c true the peaks are in Y direction (default: true)*/
|
||||
bool yPeaks;
|
||||
/** \brief indicates whether to draw the basleine (default: \c true ) */
|
||||
bool drawBaseline;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // jkqtpgraphspeakstream_H_INCLUDED
|
@ -19,13 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpevaluatedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsvaluatedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
|
@ -26,18 +26,18 @@
|
||||
* \ingroup jkqtplotter_elements
|
||||
*/
|
||||
|
||||
/** \file jkqtpelements.h
|
||||
/** \file jkqtpgraphs.h
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
#include <QPair>
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
|
||||
#ifndef JKQTPEVALUATEDFUNCTIONELEMENTS_H
|
||||
#define JKQTPEVALUATEDFUNCTIONELEMENTS_H
|
||||
#ifndef jkqtpgraphsvaluatedfunction_H
|
||||
#define jkqtpgraphsvaluatedfunction_H
|
||||
|
||||
|
||||
|
||||
@ -287,4 +287,4 @@ class LIB_EXPORT JKQTPyFunctionLineGraph: public JKQTPxFunctionLineGraph {
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPEVALUATEDFUNCTIONELEMENTS_H
|
||||
#endif // jkqtpgraphsvaluatedfunction_H
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
@ -55,6 +55,7 @@
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplottergui/jkvanishqtoolbar.h"
|
||||
#include <QKeyEvent>
|
||||
|
||||
#ifndef JKQTPLOTTER_H
|
||||
|
570
lib/jkqtplottergui/jkqtpcomboboxes.cpp
Normal file
570
lib/jkqtplottergui/jkqtpcomboboxes.cpp
Normal file
@ -0,0 +1,570 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** \file jkqtpcomboboxes.cpp
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#include "jkqtplottergui/jkqtpcomboboxes.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include <QImage>
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPMathImageColorPaletteComboBox::JKQTPMathImageColorPaletteComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setIconSize(QSize(JKQTP_PALETTE_ICON_WIDTH,16));
|
||||
QStringList pal=JKQTPimagePlot_getPredefinedPalettes();
|
||||
clear();
|
||||
for (int i=0; i<pal.size(); i++) {
|
||||
addItem(JKQTPMathImageGetPaletteIcon(i), pal[i]);
|
||||
}
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(intIndexChanged(int)));
|
||||
}
|
||||
|
||||
JKQTPMathImageColorPalette JKQTPMathImageColorPaletteComboBox::colorPalette() const
|
||||
{
|
||||
return JKQTPMathImageColorPalette(currentIndex());
|
||||
}
|
||||
|
||||
JKQTPMathImageColorPalette JKQTPMathImageColorPaletteComboBox::currentColorPalette() const
|
||||
{
|
||||
return colorPalette();
|
||||
|
||||
}
|
||||
|
||||
JKQTPMathImageColorPalette JKQTPMathImageColorPaletteComboBox::getColorPalette() const
|
||||
{
|
||||
return colorPalette();
|
||||
}
|
||||
|
||||
void JKQTPMathImageColorPaletteComboBox::setColorPalette(JKQTPMathImageColorPalette palette)
|
||||
{
|
||||
setCurrentIndex(int(palette));
|
||||
}
|
||||
|
||||
void JKQTPMathImageColorPaletteComboBox::setCurrentColorPalette(JKQTPMathImageColorPalette palette)
|
||||
{
|
||||
setCurrentIndex(int(palette));
|
||||
}
|
||||
|
||||
void JKQTPMathImageColorPaletteComboBox::intIndexChanged(int i)
|
||||
{
|
||||
emit currentPaletteChanged(JKQTPMathImageColorPalette(i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPSymbolComboBox::JKQTPSymbolComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
clear();
|
||||
setEditable(false);
|
||||
for (int i=0; i<=JKQTPmaxSymbolID; i++) {
|
||||
addSymbol(static_cast<JKQTPgraphSymbols>(i), JKQTPgraphSymbols2NameString(static_cast<JKQTPgraphSymbols>(i)));
|
||||
}
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
JKQTPgraphSymbols JKQTPSymbolComboBox::getSymbol() const
|
||||
{
|
||||
return String2JKQTPgraphSymbols(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPSymbolComboBox::setSymbol(JKQTPgraphSymbols symbol)
|
||||
{
|
||||
int i=findData(JKQTPgraphSymbols2String(symbol));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPSymbolComboBox::setCurrentSymbol(JKQTPgraphSymbols symbol)
|
||||
{
|
||||
setSymbol(symbol);
|
||||
}
|
||||
|
||||
void JKQTPSymbolComboBox::addSymbol(JKQTPgraphSymbols symbol, const QString &name)
|
||||
{
|
||||
QPixmap pix(12,12);
|
||||
pix.fill(Qt::transparent);
|
||||
JKQTPEnhancedPainter p;
|
||||
p.begin(&pix);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
|
||||
JKQTPplotSymbol(p, 6,6,symbol,10,1,QColor("blue"), QColor("blue").lighter());
|
||||
p.end();
|
||||
addItem(QIcon(pix), name, JKQTPgraphSymbols2String(symbol));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPLinePlotStyleComboBox::JKQTPLinePlotStyleComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
defaultSymbol=JKQTPcross;
|
||||
refill();
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleComboBox::setDefaultSymbol(JKQTPgraphSymbols symbol)
|
||||
{
|
||||
defaultSymbol=symbol;
|
||||
refill();
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleComboBox::addUsedSymbol(JKQTPgraphSymbols symbol)
|
||||
{
|
||||
if (!symbols.contains(symbol)) symbols.append(symbol);
|
||||
refill();
|
||||
}
|
||||
|
||||
JKQTPgraphSymbols JKQTPLinePlotStyleComboBox::getSymbol() const
|
||||
{
|
||||
bool ok=true;
|
||||
int idx=itemData(currentIndex()).toInt(&ok);
|
||||
if (idx==-2) return JKQTPnoSymbol;
|
||||
if (idx>=0&&ok) return symbols.value(idx, defaultSymbol);
|
||||
return defaultSymbol;
|
||||
}
|
||||
|
||||
bool JKQTPLinePlotStyleComboBox::getDrawLine() const
|
||||
{
|
||||
return currentIndex()%2==0;
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleComboBox::refill()
|
||||
{
|
||||
QString txt=currentText();
|
||||
setUpdatesEnabled(false);
|
||||
clear();
|
||||
addSymbol(JKQTPnoSymbol, true, tr("line"), -2);
|
||||
addSymbol(defaultSymbol, false, JKQTPgraphSymbols2NameString(defaultSymbol), -1);
|
||||
addSymbol(defaultSymbol, true, JKQTPgraphSymbols2NameString(defaultSymbol)+tr("+line"), -1);
|
||||
for (int i=0; i<symbols.size(); i++) {
|
||||
if (symbols[i]!=defaultSymbol) {
|
||||
addSymbol(symbols[i], false, JKQTPgraphSymbols2NameString(symbols[i]), i);
|
||||
addSymbol(symbols[i], true, JKQTPgraphSymbols2NameString(symbols[i])+tr("+line"), i);
|
||||
}
|
||||
}
|
||||
addSymbol(JKQTPnoSymbol, false, "none", -2);
|
||||
int idx=findText(txt);
|
||||
if (idx>=0) setCurrentIndex(idx);
|
||||
else setCurrentIndex(0);
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleComboBox::addSymbol(JKQTPgraphSymbols symbol, bool line, const QString &name, const QVariant &data)
|
||||
{
|
||||
QPixmap pix(12,12);
|
||||
pix.fill(Qt::transparent);
|
||||
JKQTPEnhancedPainter p;
|
||||
p.begin(&pix);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
|
||||
JKQTPplotSymbol(p, 6,6,symbol,7,1,QColor("blue"), QColor("blue").lighter());
|
||||
p.setPen(QColor("blue"));
|
||||
if (line) p.drawLine(0,6,12,6);
|
||||
p.end();
|
||||
addItem(QIcon(pix), name, data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
JKQTPerrorPlotstyleComboBox::JKQTPerrorPlotstyleComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
addSymbol(JKQTPnoError, tr("none"), QIcon(":/JKQTPlotter/jkqtp_enone.png"));
|
||||
addSymbol(JKQTPerrorLines, tr("error lines"), QIcon(":/JKQTPlotter/jkqtp_elines.png"));
|
||||
addSymbol(JKQTPerrorBars, tr("error bars"), QIcon(":/JKQTPlotter/jkqtp_ebars.png"));
|
||||
addSymbol(JKQTPerrorSimpleBars, tr("simple error bars"), QIcon(":/JKQTPlotter/jkqtp_esbars.png"));
|
||||
addSymbol(JKQTPerrorPolygons, tr("error polygons"), QIcon(":/JKQTPlotter/jkqtp_epoly.png"));
|
||||
addSymbol(JKQTPerrorBarsLines, tr("bars + lines"), QIcon(":/JKQTPlotter/jkqtp_elinesbars.png"));
|
||||
addSymbol(JKQTPerrorBarsPolygons, tr("bars + polygons"), QIcon(":/JKQTPlotter/jkqtp_epolybars.png"));
|
||||
addSymbol(JKQTPerrorSimpleBarsLines, tr("simple bars + lines"), QIcon(":/JKQTPlotter/jkqtp_elinessbars.png"));
|
||||
addSymbol(JKQTPerrorSimpleBarsPolygons, tr("simple bars + polygons"), QIcon(":/JKQTPlotter/jkqtp_epolysbars.png"));
|
||||
addSymbol(JKQTPerrorBoxes, tr("boxes"), QIcon(":/JKQTPlotter/jkqtp_eboxes.png"));
|
||||
addSymbol(JKQTPerrorEllipses, tr("ellipses"), QIcon(":/JKQTPlotter/jkqtp_eellipses.png"));
|
||||
setCurrentIndex(2);
|
||||
}
|
||||
|
||||
JKQTPerrorPlotstyle JKQTPerrorPlotstyleComboBox::getErrorStyle() const
|
||||
{
|
||||
return String2JKQTPerrorPlotstyle(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPerrorPlotstyleComboBox::setSymbol(JKQTPerrorPlotstyle symbol)
|
||||
{
|
||||
int i=findData(JKQTPerrorPlotstyle2String(symbol));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPerrorPlotstyleComboBox::setCurrentErrorStyle(JKQTPerrorPlotstyle symbol)
|
||||
{
|
||||
int i=findData(JKQTPerrorPlotstyle2String(symbol));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
|
||||
}
|
||||
|
||||
void JKQTPerrorPlotstyleComboBox::addSymbol(JKQTPerrorPlotstyle symbol, const QString &name, const QIcon& icon)
|
||||
{
|
||||
addItem(icon, name, JKQTPerrorPlotstyle2String(symbol));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPkeyPositionComboBox::JKQTPkeyPositionComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
addPosition(JKQTPkeyInsideTopRight, tr("inside, top-right"), QIcon(":/JKQTPlotter/jkqtp_key_itr.png"));
|
||||
addPosition(JKQTPkeyInsideTopLeft, tr("inside, top-left"), QIcon(":/JKQTPlotter/jkqtp_key_itl.png"));
|
||||
addPosition(JKQTPkeyInsideBottomLeft, tr("inside, bottom-left"), QIcon(":/JKQTPlotter/jkqtp_key_ibl.png"));
|
||||
addPosition(JKQTPkeyInsideBottomRight, tr("inside, bottom-right"), QIcon(":/JKQTPlotter/jkqtp_key_ibr.png"));
|
||||
addPosition(JKQTPkeyOutsideTopRight, tr("outside, top-right"), QIcon(":/JKQTPlotter/jkqtp_key_otr.png"));
|
||||
addPosition(JKQTPkeyOutsideTopLeft, tr("outside, top-left"), QIcon(":/JKQTPlotter/jkqtp_key_otl.png"));
|
||||
addPosition(JKQTPkeyOutsideLeftTop, tr("outside, left-top"), QIcon(":/JKQTPlotter/jkqtp_key_olt.png"));
|
||||
addPosition(JKQTPkeyOutsideLeftBottom, tr("outside, left-bottom"), QIcon(":/JKQTPlotter/jkqtp_key_olb.png"));
|
||||
addPosition(JKQTPkeyOutsideBottomRight, tr("outside, bottom-right"), QIcon(":/JKQTPlotter/jkqtp_key_obr.png"));
|
||||
addPosition(JKQTPkeyOutsideBottomLeft, tr("outside, bottom-left"), QIcon(":/JKQTPlotter/jkqtp_key_obl.png"));
|
||||
addPosition(JKQTPkeyOutsideRightTop, tr("outside, right-top"), QIcon(":/JKQTPlotter/jkqtp_key_ort.png"));
|
||||
addPosition(JKQTPkeyOutsideRightBottom, tr("outside, right-bottom"), QIcon(":/JKQTPlotter/jkqtp_key_orb.png"));
|
||||
setCurrentIndex(0);
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(posChanged(int)));
|
||||
}
|
||||
|
||||
JKQTPkeyPosition JKQTPkeyPositionComboBox::getPosition() const
|
||||
{
|
||||
return String2JKQTPkeyPosition(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPkeyPositionComboBox::setPosition(JKQTPkeyPosition position)
|
||||
{
|
||||
int i=findData(JKQTPkeyPosition2String(position));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPkeyPositionComboBox::addPosition(JKQTPkeyPosition position, const QString &name, const QIcon &icon)
|
||||
{
|
||||
addItem(icon, name, JKQTPkeyPosition2String(position));
|
||||
}
|
||||
|
||||
void JKQTPkeyPositionComboBox::posChanged(int index)
|
||||
{
|
||||
emit currentPositionChanged(String2JKQTPkeyPosition(itemData(index).toString()));
|
||||
}
|
||||
|
||||
JKQTPkeyLayoutComboBox::JKQTPkeyLayoutComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
addKeyLayout(JKQTPkeyLayoutOneColumn, tr("one column"));
|
||||
addKeyLayout(JKQTPkeyLayoutOneRow, tr("one row"));
|
||||
addKeyLayout(JKQTPkeyLayoutMultiColumn, tr("multiple columns"));
|
||||
setCurrentIndex(0);
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(currentIndexChangedP(int)));
|
||||
}
|
||||
|
||||
JKQTPkeyLayout JKQTPkeyLayoutComboBox::getKeyLayout() const
|
||||
{
|
||||
return String2JKQTPkeyLayout(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPkeyLayoutComboBox::setKeyLayout(JKQTPkeyLayout position)
|
||||
{
|
||||
int i=findData(JKQTPkeyLayout2String(position));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPkeyLayoutComboBox::addKeyLayout(JKQTPkeyLayout position, const QString &name)
|
||||
{
|
||||
addItem(name, JKQTPkeyLayout2String(position));
|
||||
}
|
||||
|
||||
void JKQTPkeyLayoutComboBox::currentIndexChangedP(int index)
|
||||
{
|
||||
emit currentLayoutChanged(String2JKQTPkeyLayout(itemData(index).toString()));
|
||||
}
|
||||
|
||||
JKQTPlabelPositionComboBox::JKQTPlabelPositionComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
addPosition(JKQTPlabelCenter, tr("center"));
|
||||
addPosition(JKQTPlabelMin, tr("left"));
|
||||
addPosition(JKQTPlabelMax, tr("right"));
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
JKQTPlabelPosition JKQTPlabelPositionComboBox::getPosition() const
|
||||
{
|
||||
return String2JKQTPlabelPosition(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPlabelPositionComboBox::setPosition(JKQTPlabelPosition position)
|
||||
{
|
||||
int i=findData(JKQTPlabelPosition2String(position));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPlabelPositionComboBox::addPosition(JKQTPlabelPosition position, const QString &name, const QIcon &icon)
|
||||
{
|
||||
addItem(icon, name, JKQTPlabelPosition2String(position));
|
||||
}
|
||||
|
||||
JKQTPCAlabelTypeComboBox::JKQTPCAlabelTypeComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
addLabelType(JKQTPCALTexponent, tr("exponent"), QIcon(":/JKQTPlotter/jkqtp_ticks_exp.png"));
|
||||
addLabelType(JKQTPCALTdefault, tr("default"), QIcon(":/JKQTPlotter/jkqtp_ticks_default.png"));
|
||||
addLabelType(JKQTPCALTexponentCharacter, tr("character"), QIcon(":/JKQTPlotter/jkqtp_ticks_expchar.png"));
|
||||
addLabelType(JKQTPCALTtime, tr("time"), QIcon(":/JKQTPlotter/jkqtp_ticks_time.png"));
|
||||
addLabelType(JKQTPCALTdate, tr("date"), QIcon(":/JKQTPlotter/jkqtp_ticks_date.png"));
|
||||
addLabelType(JKQTPCALTdatetime, tr("datetime"), QIcon(":/JKQTPlotter/jkqtp_ticks_datetime.png"));
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
JKQTPCAlabelType JKQTPCAlabelTypeComboBox::getLabelType() const
|
||||
{
|
||||
return String2JKQTPCAlabelType(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPCAlabelTypeComboBox::setLabelType(JKQTPCAlabelType position)
|
||||
{
|
||||
int i=findData(JKQTPCAlabelType2String(position));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPCAlabelTypeComboBox::addLabelType(JKQTPCAlabelType position, const QString &name, const QIcon& icon)
|
||||
{
|
||||
addItem(icon, name, JKQTPCAlabelType2String(position));
|
||||
}
|
||||
|
||||
JKQTPCAdrawModeComboBox::JKQTPCAdrawModeComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
addDrawMode(JKQTPCADMcomplete, tr("complete"), QIcon(":/JKQTPlotter/jkqtp_axis_complete.png"));
|
||||
addDrawMode(JKQTPCADMticksAndLabels, tr("tick+lab."), QIcon(":/JKQTPlotter/jkqtp_axis_ticksandlabels.png"));
|
||||
addDrawMode(JKQTPCADMticks, tr("tick"), QIcon(":/JKQTPlotter/jkqtp_axis_ticks.png"));
|
||||
addDrawMode(JKQTPCADMline, tr("line"), QIcon(":/JKQTPlotter/jkqtp_axis_line.png"));
|
||||
addDrawMode(JKQTPCADMnone, tr("none"), QIcon(":/JKQTPlotter/jkqtp_axis_none.png"));
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
JKQTPCAdrawMode JKQTPCAdrawModeComboBox::getDrawMode() const
|
||||
{
|
||||
return String2JKQTPCAdrawMode(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPCAdrawModeComboBox::setDrawMode(JKQTPCAdrawMode position)
|
||||
{
|
||||
int i=findData(JKQTPCAdrawMode2String(position));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPCAdrawModeComboBox::addDrawMode(JKQTPCAdrawMode position, const QString &name, const QIcon &icon)
|
||||
{
|
||||
addItem(icon, name, JKQTPCAdrawMode2String(position));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPLinePlotStyleWithSymbolSizeComboBox::JKQTPLinePlotStyleWithSymbolSizeComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setEditable(false);
|
||||
defaultSymbol=JKQTPcross;
|
||||
defaultSize=10;
|
||||
refill();
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleWithSymbolSizeComboBox::setDefaultSymbol(JKQTPgraphSymbols symbol, double size)
|
||||
{
|
||||
defaultSymbol=symbol;
|
||||
defaultSize=size;
|
||||
refill();
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleWithSymbolSizeComboBox::addUsedSymbol(JKQTPgraphSymbols symbol, double symbolSize, bool line)
|
||||
{
|
||||
styleData d;
|
||||
d.symbol=symbol;
|
||||
d.symbolSize=symbolSize;
|
||||
d.line=line;
|
||||
if (!symbols.contains(d)) symbols.append(d);
|
||||
refill();
|
||||
}
|
||||
|
||||
JKQTPgraphSymbols JKQTPLinePlotStyleWithSymbolSizeComboBox::getSymbol() const
|
||||
{
|
||||
QVariant idxV=itemData(currentIndex());
|
||||
bool ok=false;
|
||||
int idx=idxV.toInt(&ok);
|
||||
if (idxV.isValid() && ok) {
|
||||
if (idx>=0 && idx<symbols.size()) return symbols[idx].symbol;
|
||||
if (idx==-4) return JKQTPnoSymbol;
|
||||
if (idx==-3) return JKQTPnoSymbol;
|
||||
return defaultSymbol;
|
||||
}
|
||||
return JKQTPnoSymbol;
|
||||
}
|
||||
|
||||
bool JKQTPLinePlotStyleWithSymbolSizeComboBox::getDrawLine() const
|
||||
{
|
||||
QVariant idxV=itemData(currentIndex());
|
||||
bool ok=false;
|
||||
int idx=idxV.toInt(&ok);
|
||||
if (idxV.isValid() && ok) {
|
||||
if (idx==-3) return true;
|
||||
if (idx==-1) return true;
|
||||
if (idx>=0 && idx<symbols.size()) return symbols[idx].line;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
double JKQTPLinePlotStyleWithSymbolSizeComboBox::getSymbolSize() const
|
||||
{
|
||||
QVariant idxV=itemData(currentIndex());
|
||||
bool ok=false;
|
||||
int idx=idxV.toInt(&ok);
|
||||
if (idxV.isValid() && ok) {
|
||||
if (idx>=0 && idx<symbols.size()) return symbols[idx].symbolSize;
|
||||
return defaultSize;
|
||||
}
|
||||
return defaultSize;
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleWithSymbolSizeComboBox::refill()
|
||||
{
|
||||
QString txt=currentText();
|
||||
setUpdatesEnabled(false);
|
||||
clear();
|
||||
addSymbol(JKQTPnoSymbol, true, defaultSize, tr("line"), -3);
|
||||
addSymbol(defaultSymbol, false, defaultSize, JKQTPgraphSymbols2NameString(defaultSymbol), -2);
|
||||
addSymbol(defaultSymbol, true, defaultSize, JKQTPgraphSymbols2NameString(defaultSymbol)+tr("+line"), -1);
|
||||
for (int i=0; i<symbols.size(); i++) {
|
||||
if (symbols[i].symbol!=defaultSymbol||symbols[i].symbolSize!=defaultSize) {
|
||||
addSymbol(symbols[i].symbol, symbols[i].line, symbols[i].symbolSize, JKQTPgraphSymbols2NameString(symbols[i].symbol), i);
|
||||
}
|
||||
}
|
||||
addSymbol(JKQTPnoSymbol, false, defaultSize, "none", -4);
|
||||
int idx=findText(txt);
|
||||
if (idx>=0) setCurrentIndex(idx);
|
||||
else setCurrentIndex(0);
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void JKQTPLinePlotStyleWithSymbolSizeComboBox::addSymbol(JKQTPgraphSymbols symbol, bool line, double symbolSize, const QString &name, const QVariant &data)
|
||||
{
|
||||
int pixSize=qMax(16.0, 1.2*symbolSize);
|
||||
QPixmap pix(pixSize, pixSize);
|
||||
pix.fill(Qt::transparent);
|
||||
JKQTPEnhancedPainter p;
|
||||
p.begin(&pix);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
|
||||
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
|
||||
JKQTPplotSymbol(p, double(pixSize)/2.0,double(pixSize)/2.0,symbol,symbolSize,1,QColor("blue"), QColor("blue").lighter());
|
||||
p.setPen(QColor("blue"));
|
||||
if (line) p.drawLine(QLineF(0,double(pixSize)/2.0,pixSize,double(pixSize)/2.0));
|
||||
p.end();
|
||||
addItem(QIcon(pix), name, data);
|
||||
}
|
||||
|
||||
|
||||
bool JKQTPLinePlotStyleWithSymbolSizeComboBox::styleData::operator==(const JKQTPLinePlotStyleWithSymbolSizeComboBox::styleData &other) const
|
||||
{
|
||||
return (symbol==other.symbol && symbolSize==other.symbolSize && line==other.line);
|
||||
}
|
||||
|
||||
|
||||
JKQTPstepTypeComboBox::JKQTPstepTypeComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
clear();
|
||||
setEditable(false);
|
||||
addStep(JKQTPstepType::JKQTPstepLeft, JKQTPstepType2String(JKQTPstepType::JKQTPstepLeft));
|
||||
addStep(JKQTPstepType::JKQTPstepCenter, JKQTPstepType2String(JKQTPstepType::JKQTPstepCenter));
|
||||
addStep(JKQTPstepType::JKQTPstepRight, JKQTPstepType2String(JKQTPstepType::JKQTPstepRight));
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
JKQTPstepType JKQTPstepTypeComboBox::getStepType() const
|
||||
{
|
||||
return String2JKQTPstepType(itemData(currentIndex()).toString());
|
||||
}
|
||||
|
||||
void JKQTPstepTypeComboBox::setStepType(JKQTPstepType step)
|
||||
{
|
||||
int i=findData(JKQTPstepType2String(step));
|
||||
if (i>=0) setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void JKQTPstepTypeComboBox::setCurrentStepType(JKQTPstepType step)
|
||||
{
|
||||
setStepType(step);
|
||||
}
|
||||
|
||||
void JKQTPstepTypeComboBox::addStep(JKQTPstepType step, const QString &name, const QIcon &icon)
|
||||
{
|
||||
addItem(icon, name, JKQTPstepType2String(step));
|
||||
}
|
||||
|
||||
|
||||
JKQTPImageModifierModeComboBox::JKQTPImageModifierModeComboBox(QWidget * /*parent*/)
|
||||
{
|
||||
addMode(JKQTPMathImageBase::ModifyNone, tr("none"));
|
||||
addMode(JKQTPMathImageBase::ModifyValue, tr("value"));
|
||||
addMode(JKQTPMathImageBase::ModifySaturation, tr("saturation"));
|
||||
addMode(JKQTPMathImageBase::ModifyAlpha, tr("alpha"));
|
||||
}
|
||||
|
||||
JKQTPMathImageBase::ModifierMode JKQTPImageModifierModeComboBox::getModifierMode() const
|
||||
{
|
||||
bool ok=false;
|
||||
JKQTPMathImageBase::ModifierMode m=JKQTPMathImageBase::ModifyNone;
|
||||
if (currentIndex()>=0) m=JKQTPMathImageBase::ModifierMode(itemData(currentIndex()).toInt(&ok));
|
||||
if (!ok) m=JKQTPMathImageBase::ModifyNone;
|
||||
return m;
|
||||
}
|
||||
|
||||
void JKQTPImageModifierModeComboBox::setModifierMode(JKQTPMathImageBase::ModifierMode mode)
|
||||
{
|
||||
setCurrentIndex(findData((int)mode));
|
||||
}
|
||||
|
||||
void JKQTPImageModifierModeComboBox::addMode(JKQTPMathImageBase::ModifierMode mode, const QString &name, const QIcon &icon)
|
||||
{
|
||||
addItem(icon, name, (int)mode);
|
||||
}
|
266
lib/jkqtplottergui/jkqtpcomboboxes.h
Normal file
266
lib/jkqtplottergui/jkqtpcomboboxes.h
Normal file
@ -0,0 +1,266 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtpcomboboxes diverse comboboxes for properties of JKQtPlotter
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file jkqtpcomboboxes.h
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#ifndef JKQTPCOMBOBOXES_H
|
||||
#define JKQTPCOMBOBOXES_H
|
||||
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
|
||||
|
||||
|
||||
/*! \brief class to plot an image from an 2-dimensional array of values
|
||||
\ingroup jkqtplotter_imagelots
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPMathImageColorPaletteComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPMathImageColorPaletteComboBox(QWidget* parent=nullptr);
|
||||
JKQTPMathImageColorPalette colorPalette() const;
|
||||
JKQTPMathImageColorPalette currentColorPalette() const;
|
||||
JKQTPMathImageColorPalette getColorPalette() const;
|
||||
void setColorPalette(JKQTPMathImageColorPalette palette);
|
||||
void setCurrentColorPalette(JKQTPMathImageColorPalette palette);
|
||||
signals:
|
||||
void currentPaletteChanged(JKQTPMathImageColorPalette palette);
|
||||
protected slots:
|
||||
void intIndexChanged(int i);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPCAdrawMode
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPCAdrawModeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPCAdrawModeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPCAdrawMode getDrawMode() const;
|
||||
void setDrawMode(JKQTPCAdrawMode position);
|
||||
protected:
|
||||
void addDrawMode(JKQTPCAdrawMode position, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPCAlabelType
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPCAlabelTypeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPCAlabelTypeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPCAlabelType getLabelType() const;
|
||||
void setLabelType(JKQTPCAlabelType position);
|
||||
protected:
|
||||
void addLabelType(JKQTPCAlabelType position, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPlabelPosition
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPlabelPositionComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPlabelPositionComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPlabelPosition getPosition() const;
|
||||
void setPosition(JKQTPlabelPosition position);
|
||||
protected:
|
||||
void addPosition(JKQTPlabelPosition position, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPkeyPosition
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPkeyPositionComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPkeyPositionComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPkeyPosition getPosition() const;
|
||||
void setPosition(JKQTPkeyPosition position);
|
||||
signals:
|
||||
void currentPositionChanged(JKQTPkeyPosition pos);
|
||||
protected:
|
||||
void addPosition(JKQTPkeyPosition position, const QString& name, const QIcon& icon=QIcon());
|
||||
protected slots:
|
||||
void posChanged(int index);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPkeyPosition
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPkeyLayoutComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPkeyLayoutComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPkeyLayout getKeyLayout() const;
|
||||
void setKeyLayout(JKQTPkeyLayout layout);
|
||||
signals:
|
||||
void currentLayoutChanged(JKQTPkeyLayout layout);
|
||||
protected:
|
||||
void addKeyLayout(JKQTPkeyLayout layout, const QString& name);
|
||||
protected slots:
|
||||
void currentIndexChangedP(int index);
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPerrorPlotstyle
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPerrorPlotstyleComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPerrorPlotstyleComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPerrorPlotstyle getErrorStyle() const;
|
||||
void setSymbol(JKQTPerrorPlotstyle symbol);
|
||||
void setCurrentErrorStyle(JKQTPerrorPlotstyle symbol);
|
||||
protected:
|
||||
void addSymbol(JKQTPerrorPlotstyle symbol, const QString& name, const QIcon &icon=QIcon());
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPgraphSymbols
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPSymbolComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPSymbolComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPgraphSymbols getSymbol() const;
|
||||
void setSymbol(JKQTPgraphSymbols symbol);
|
||||
void setCurrentSymbol(JKQTPgraphSymbols symbol);
|
||||
protected:
|
||||
void addSymbol(JKQTPgraphSymbols symbol, const QString& name);
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox to select whether a line, symbols or both should be displayed
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPLinePlotStyleComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPLinePlotStyleComboBox(QWidget* parent=nullptr);
|
||||
|
||||
void setDefaultSymbol(JKQTPgraphSymbols symbol);
|
||||
void addUsedSymbol(JKQTPgraphSymbols symbol);
|
||||
|
||||
JKQTPgraphSymbols getSymbol() const;
|
||||
bool getDrawLine() const;
|
||||
protected:
|
||||
void refill();
|
||||
void addSymbol(JKQTPgraphSymbols symbol, bool line, const QString& name=QString(""), const QVariant& data=QVariant());
|
||||
QList<JKQTPgraphSymbols> symbols;
|
||||
JKQTPgraphSymbols defaultSymbol;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox to select whether a line, symbols or both should be displayed, in addition to JKQTPLinePlotStyleComboBox this may also have different symbol sizes!
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPLinePlotStyleWithSymbolSizeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPLinePlotStyleWithSymbolSizeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
void setDefaultSymbol(JKQTPgraphSymbols symbol, double size);
|
||||
void addUsedSymbol(JKQTPgraphSymbols symbol, double symbolSize, bool line);
|
||||
|
||||
JKQTPgraphSymbols getSymbol() const;
|
||||
bool getDrawLine() const;
|
||||
double getSymbolSize() const;
|
||||
protected:
|
||||
void refill();
|
||||
void addSymbol(JKQTPgraphSymbols symbol, bool line, double symbolSize, const QString& name=QString(""), const QVariant& data=QVariant());
|
||||
struct styleData {
|
||||
JKQTPgraphSymbols symbol;
|
||||
bool line;
|
||||
double symbolSize;
|
||||
bool operator==(const styleData& other)const;
|
||||
};
|
||||
|
||||
QList<styleData> symbols;
|
||||
JKQTPgraphSymbols defaultSymbol;
|
||||
double defaultSize;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPstepType
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPstepTypeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPstepTypeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPstepType getStepType() const;
|
||||
void setStepType(JKQTPstepType step);
|
||||
void setCurrentStepType(JKQTPstepType step);
|
||||
protected:
|
||||
void addStep(JKQTPstepType step, const QString& name, const QIcon &icon=QIcon());
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPMathImageBase::ModifierMode
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPImageModifierModeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPImageModifierModeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPMathImageBase::ModifierMode getModifierMode() const;
|
||||
void setModifierMode(JKQTPMathImageBase::ModifierMode mode);
|
||||
protected:
|
||||
void addMode(JKQTPMathImageBase::ModifierMode mode, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
#endif // JKQTPCOMBOBOXES_H
|
69
lib/jkqtplottergui/jkqtpenhancedspinboxes.cpp
Normal file
69
lib/jkqtplottergui/jkqtpenhancedspinboxes.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** \file jkqtpenhancedspinboxes.cpp
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
#include "jkqtplottergui/jkqtpenhancedspinboxes.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPEnhancedDoubleSpinBox::JKQTPEnhancedDoubleSpinBox(QWidget *parent):
|
||||
QDoubleSpinBox(parent)
|
||||
{
|
||||
connect(this, SIGNAL(editingFinished()), this, SLOT(intEditingFinished()));
|
||||
}
|
||||
|
||||
JKQTPEnhancedDoubleSpinBox::~JKQTPEnhancedDoubleSpinBox()
|
||||
{
|
||||
disconnect(this, SIGNAL(editingFinished()), this, SLOT(intEditingFinished()));
|
||||
}
|
||||
|
||||
void JKQTPEnhancedDoubleSpinBox::intEditingFinished()
|
||||
{
|
||||
emit editingFinished(value());
|
||||
}
|
||||
|
||||
|
||||
JKQTPEnhancedSpinBox::JKQTPEnhancedSpinBox(QWidget *parent):
|
||||
QSpinBox(parent)
|
||||
{
|
||||
connect(this, SIGNAL(editingFinished()), this, SLOT(intEditingFinished()));
|
||||
}
|
||||
|
||||
JKQTPEnhancedSpinBox::~JKQTPEnhancedSpinBox()
|
||||
{
|
||||
disconnect(this, SIGNAL(editingFinished()), this, SLOT(intEditingFinished()));
|
||||
}
|
||||
|
||||
void JKQTPEnhancedSpinBox::intEditingFinished()
|
||||
{
|
||||
emit editingFinished(value());
|
||||
}
|
||||
|
||||
|
70
lib/jkqtplottergui/jkqtpenhancedspinboxes.h
Normal file
70
lib/jkqtplottergui/jkqtpenhancedspinboxes.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
This software is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtptools Tool Functions and Definitions
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
/** \file jkqtptools.h
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
|
||||
#ifndef jkqtpenhancedspinboxes_H_INCLUDED
|
||||
#define jkqtpenhancedspinboxes_H_INCLUDED
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
/*! \brief enhanced QDoubleSpinBox
|
||||
\ingroup jkqtptools
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedDoubleSpinBox : public QDoubleSpinBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPEnhancedDoubleSpinBox(QWidget* parent=nullptr);
|
||||
~JKQTPEnhancedDoubleSpinBox();
|
||||
signals:
|
||||
void editingFinished(double value);
|
||||
protected slots:
|
||||
void intEditingFinished();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief enhanced QDoubleSpinBox
|
||||
\ingroup jkqtptools
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedSpinBox : public QSpinBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPEnhancedSpinBox(QWidget* parent=nullptr);
|
||||
~JKQTPEnhancedSpinBox();
|
||||
signals:
|
||||
void editingFinished(int value);
|
||||
protected slots:
|
||||
void intEditingFinished();
|
||||
};
|
||||
|
||||
#endif // jkqtpenhancedspinboxes_H_INCLUDED
|
670
lib/jkqtplottergui/jkqtpenhancedtableview.cpp
Normal file
670
lib/jkqtplottergui/jkqtpenhancedtableview.cpp
Normal file
@ -0,0 +1,670 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** \file JKQTPEnhancedTableView.cpp
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
#include "jkqtplottergui/jkqtpenhancedtableview.h"
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QKeyEvent>
|
||||
#include <QClipboard>
|
||||
#include <QDialog>
|
||||
#include <QGridLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHeaderView>
|
||||
#include <QPrintDialog>
|
||||
#include <QLabel>
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplottertools/jkqtpenhancedpainter.h"
|
||||
|
||||
|
||||
|
||||
JKQTPEnhancedTableView::JKQTPEnhancedTableView(QWidget *parent):
|
||||
QTableView(parent)
|
||||
{
|
||||
setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
QAction* act;
|
||||
|
||||
act=new QAction(QIcon(":/JKQTPlotter/jkqtp_copy16.png"), tr("Copy Selection to Clipboard (for Excel ...)"), this);
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(copySelectionToExcel()));
|
||||
addAction(act);
|
||||
act=new QAction(QIcon(":/JKQTPlotter/jkqtp_copy16_nohead.png"), tr("Copy Selection to clipboard (for Excel ...) without header row/column"), this);
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(copySelectionToExcelNoHead()));
|
||||
addAction(act);
|
||||
act=new QAction(QIcon(":/JKQTPlotter/jkqtp_copy16.png"), tr("Copy Selection to Clipboard (as CSV)"), this);
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(copySelectionToCSV()));
|
||||
addAction(act);
|
||||
act=new QAction(QIcon(":/JKQTPlotter/jkqtp_copy16_nohead.png"), tr("Copy Selection to clipboard (as CSV ...) without header row/column"), this);
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(copySelectionToCSVNoHead()));
|
||||
addAction(act);
|
||||
act=new QAction(QIcon(":/JKQTPlotter/jkqtp_printtable.png"), tr("Print Table"), this);
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(print()));
|
||||
addAction(act);
|
||||
printAction=act;
|
||||
}
|
||||
|
||||
JKQTPEnhancedTableView::~JKQTPEnhancedTableView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString JKQTPEnhancedTableView::toHtml(int borderWidth, bool /*non_breaking*/, int fontSizePt) const
|
||||
{
|
||||
if (!model()) return "";
|
||||
QString fsstyle="";
|
||||
if (fontSizePt>0) {
|
||||
fsstyle=QString(" font-size: %1pt;").arg(fontSizePt);
|
||||
}
|
||||
QString html=QString("<table border=\"%1\" cellspacing=\"0\" cellpadding=\"0\">").arg(borderWidth);
|
||||
for (int row=-1; row<model()->rowCount(); row++) {
|
||||
html+="<tr>";
|
||||
if (row==-1) {
|
||||
for (int col=-1; col<model()->columnCount(); col++) {
|
||||
html+=QString("<th style=\"white-space: nowrap;%1\"><nobr>").arg(fsstyle);
|
||||
if (col>=0) {
|
||||
html+=model()->headerData(col, Qt::Horizontal).toString();
|
||||
}
|
||||
html+="</nobr></th>";
|
||||
}
|
||||
} else {
|
||||
for (int col=-1; col<model()->columnCount(); col++) {
|
||||
if (col==-1) {
|
||||
html+=QString("<th style=\"white-space: nowrap;%1\"><nobr>").arg(fsstyle);
|
||||
html+=model()->headerData(row, Qt::Vertical).toString();
|
||||
html+="</nobr></th>";
|
||||
} else {
|
||||
QModelIndex index=model()->index(row, col);
|
||||
QVariant check=index.data(Qt::CheckStateRole);
|
||||
QBrush back=index.data(Qt::BackgroundRole).value<QBrush>();
|
||||
QString style=fsstyle+"white-space: nowrap; ";
|
||||
//qDebug()<<"r="<<row<<"\tc="<<col<<"\tcolor="<<back.color().name();
|
||||
if (back.color()!=QColor(0,0,0) && index.data(Qt::BackgroundRole).isValid()) style=QString("background: %1;").arg(back.color().name());
|
||||
if (style.isEmpty()) html+=QString("<td style=\"%1\"><nobr>").arg(fsstyle);
|
||||
else html+=QString("<td style=\"%1\"><nobr>").arg(style);
|
||||
if (check.isValid()) {
|
||||
if (check.toInt()!=0) {
|
||||
html+= QString("|×| ");
|
||||
} else {
|
||||
html+= QString("| | ");
|
||||
}
|
||||
}
|
||||
html+=index.data().toString();
|
||||
html+="</nobr></td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
html+="</tr>";
|
||||
|
||||
}
|
||||
html+="</table>";
|
||||
return html;
|
||||
}
|
||||
|
||||
void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
|
||||
{
|
||||
if (!model()) return;
|
||||
if (!selectionModel()) return;
|
||||
QModelIndexList sel=selectionModel()->selectedIndexes();
|
||||
QLocale loc=QLocale::system();
|
||||
loc.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
if (sel.size()==1) {
|
||||
QVariant vdata=sel[0].data(copyrole);
|
||||
QString txt="";
|
||||
switch (vdata.type()) {
|
||||
case QVariant::Int:
|
||||
case QVariant::LongLong:
|
||||
case QVariant::UInt:
|
||||
case QVariant::ULongLong:
|
||||
case QVariant::Bool:
|
||||
txt=vdata.toString();
|
||||
break;
|
||||
case QVariant::Double:
|
||||
txt=loc.toString(vdata.toDouble());
|
||||
break;
|
||||
case QVariant::PointF:
|
||||
txt=loc.toString(vdata.toPointF().x());
|
||||
break;
|
||||
default:
|
||||
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
|
||||
break;
|
||||
}
|
||||
QApplication::clipboard()->setText(txt);
|
||||
} else {
|
||||
QSet<int> rows, cols;
|
||||
int colmin=0;
|
||||
int rowmin=0;
|
||||
for (int i=0; i<sel.size(); i++) {
|
||||
int r=sel[i].row();
|
||||
int c=sel[i].column();
|
||||
rows.insert(r);
|
||||
cols.insert(c);
|
||||
if (i==0) {
|
||||
colmin=c;
|
||||
rowmin=r;
|
||||
} else {
|
||||
if (c<colmin) colmin=c;
|
||||
if (r<rowmin) rowmin=r;
|
||||
}
|
||||
}
|
||||
QList<int> rowlist=QList<int>::fromSet(rows);
|
||||
qSort(rowlist.begin(), rowlist.end());
|
||||
QList<int> collist=QList<int>::fromSet(cols);
|
||||
qSort(collist.begin(), collist.end());
|
||||
int rowcnt=rowlist.size();
|
||||
int colcnt=collist.size();
|
||||
QList<QStringList> data;
|
||||
|
||||
// header row:
|
||||
//
|
||||
// <EMPTY> | <HOR_HEDER1> | <HOR_HEADER2> | ...
|
||||
QStringList hrow;
|
||||
if (storeHead) {
|
||||
hrow.append(""); // empty header for first column (vertical headers!)
|
||||
for (int c=0; c<colcnt; c++) {
|
||||
hrow.append(QString("\"%1\"").arg(model()->headerData(collist[c], Qt::Horizontal).toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")));
|
||||
}
|
||||
data.append(hrow);
|
||||
}
|
||||
|
||||
// now add dta rows:
|
||||
//
|
||||
// <~~~~~~~~~ colcnt times ~~~~~~~~~~>
|
||||
// <VER_HEADER> | <EMPTY> | <EMPTY> | ... | <EMPTY>
|
||||
for (int r=0; r<rowcnt; r++) {
|
||||
QStringList row;
|
||||
if (storeHead) row.append(QString("\"%1\"").arg(model()->headerData(rowlist[r], Qt::Vertical).toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "))); // vertical header
|
||||
for (int c=0; c<colcnt; c++) {
|
||||
row.append(""); // empty columns for data
|
||||
}
|
||||
data.append(row);
|
||||
}
|
||||
for (int i=0; i<sel.size(); i++) {
|
||||
int r=rowlist.indexOf(sel[i].row());
|
||||
int c=collist.indexOf(sel[i].column());
|
||||
QVariant vdata=sel[i].data(copyrole);
|
||||
QString txt="";
|
||||
switch (vdata.type()) {
|
||||
case QVariant::Int:
|
||||
case QVariant::LongLong:
|
||||
case QVariant::UInt:
|
||||
case QVariant::ULongLong:
|
||||
case QVariant::Bool:
|
||||
txt=vdata.toString();
|
||||
break;
|
||||
case QVariant::Double:
|
||||
txt=loc.toString(vdata.toDouble());
|
||||
break;
|
||||
case QVariant::PointF:
|
||||
txt=loc.toString(vdata.toPointF().x());
|
||||
break;
|
||||
default:
|
||||
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
|
||||
break;
|
||||
}
|
||||
int shift=0;
|
||||
if (storeHead) shift=1;
|
||||
if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt;
|
||||
}
|
||||
|
||||
QString result="";
|
||||
for (int r=0; r<data.size(); r++) {
|
||||
result+=data[r].join("\t")+"\n";
|
||||
}
|
||||
QApplication::clipboard()->setText(result);
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPEnhancedTableView::copySelectionToExcelNoHead(int copyrole)
|
||||
{
|
||||
copySelectionToExcel(copyrole, false);
|
||||
}
|
||||
|
||||
void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, const QString &separator, const QChar &decimalpoint)
|
||||
{
|
||||
if (!model()) return;
|
||||
if (!selectionModel()) return;
|
||||
QModelIndexList sel=selectionModel()->selectedIndexes();
|
||||
QLocale loc=QLocale::c();
|
||||
loc.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
if (sel.size()==1) {
|
||||
QVariant vdata=sel[0].data(copyrole);
|
||||
QString txt="";
|
||||
switch (vdata.type()) {
|
||||
case QVariant::Int:
|
||||
case QVariant::LongLong:
|
||||
case QVariant::UInt:
|
||||
case QVariant::ULongLong:
|
||||
case QVariant::Bool:
|
||||
txt=vdata.toString();
|
||||
break;
|
||||
case QVariant::Double:
|
||||
txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint);
|
||||
break;
|
||||
case QVariant::PointF:
|
||||
txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint);
|
||||
break;
|
||||
default:
|
||||
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
|
||||
break;
|
||||
}
|
||||
QApplication::clipboard()->setText(txt);
|
||||
} else {
|
||||
QSet<int> rows, cols;
|
||||
int colmin=0;
|
||||
int rowmin=0;
|
||||
for (int i=0; i<sel.size(); i++) {
|
||||
int r=sel[i].row();
|
||||
int c=sel[i].column();
|
||||
rows.insert(r);
|
||||
cols.insert(c);
|
||||
if (i==0) {
|
||||
colmin=c;
|
||||
rowmin=r;
|
||||
} else {
|
||||
if (c<colmin) colmin=c;
|
||||
if (r<rowmin) rowmin=r;
|
||||
}
|
||||
}
|
||||
QList<int> rowlist=QList<int>::fromSet(rows);
|
||||
qSort(rowlist.begin(), rowlist.end());
|
||||
QList<int> collist=QList<int>::fromSet(cols);
|
||||
qSort(collist.begin(), collist.end());
|
||||
int rowcnt=rowlist.size();
|
||||
int colcnt=collist.size();
|
||||
QList<QStringList> data;
|
||||
|
||||
// header row:
|
||||
//
|
||||
// <EMPTY> | <HOR_HEDER1> | <HOR_HEADER2> | ...
|
||||
QStringList hrow;
|
||||
if (storeHead) {
|
||||
hrow.append(""); // empty header for first column (vertical headers!)
|
||||
for (int c=0; c<colcnt; c++) {
|
||||
hrow.append(QString("\"%1\"").arg(model()->headerData(collist[c], Qt::Horizontal).toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")));
|
||||
}
|
||||
data.append(hrow);
|
||||
}
|
||||
|
||||
// now add dta rows:
|
||||
//
|
||||
// <~~~~~~~~~ colcnt times ~~~~~~~~~~>
|
||||
// <VER_HEADER> | <EMPTY> | <EMPTY> | ... | <EMPTY>
|
||||
for (int r=0; r<rowcnt; r++) {
|
||||
QStringList row;
|
||||
if (storeHead) row.append(QString("\"%1\"").arg(model()->headerData(rowlist[r], Qt::Vertical).toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "))); // vertical header
|
||||
for (int c=0; c<colcnt; c++) {
|
||||
row.append(""); // empty columns for data
|
||||
}
|
||||
data.append(row);
|
||||
}
|
||||
for (int i=0; i<sel.size(); i++) {
|
||||
int r=rowlist.indexOf(sel[i].row());
|
||||
int c=collist.indexOf(sel[i].column());
|
||||
QVariant vdata=sel[i].data(copyrole);
|
||||
QString txt="";
|
||||
switch (vdata.type()) {
|
||||
case QVariant::Int:
|
||||
case QVariant::LongLong:
|
||||
case QVariant::UInt:
|
||||
case QVariant::ULongLong:
|
||||
case QVariant::Bool:
|
||||
txt=vdata.toString();
|
||||
break;
|
||||
case QVariant::Double:
|
||||
txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint);
|
||||
break;
|
||||
case QVariant::PointF:
|
||||
txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint);
|
||||
break;
|
||||
default:
|
||||
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
|
||||
break;
|
||||
}
|
||||
int shift=0;
|
||||
if (storeHead) shift=1;
|
||||
if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt;
|
||||
}
|
||||
|
||||
QString result="";
|
||||
for (int r=0; r<data.size(); r++) {
|
||||
result+=data[r].join(separator)+"\n";
|
||||
}
|
||||
QApplication::clipboard()->setText(result);
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPEnhancedTableView::copySelectionToCSVNoHead(int copyrole, const QString &separator, const QChar &decimalpoint)
|
||||
{
|
||||
copySelectionToCSV(copyrole, false, separator, decimalpoint);
|
||||
}
|
||||
|
||||
void JKQTPEnhancedTableView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->matches(QKeySequence::Copy)) {
|
||||
copySelectionToExcel(Qt::EditRole, false);
|
||||
event->accept();
|
||||
} else if (event->matches(QKeySequence::Print)) {
|
||||
print();
|
||||
event->accept();
|
||||
} else QTableView::keyPressEvent(event);
|
||||
emit keyPressed(event->key(), event->modifiers(), event->text());
|
||||
}
|
||||
|
||||
|
||||
void JKQTPEnhancedTableView::print()
|
||||
{
|
||||
QPrinter* tablePrinter=getPrinter(nullptr);
|
||||
|
||||
if (tablePrinter) {
|
||||
QDialog* dlg=new QDialog(this);
|
||||
dlg->setWindowTitle(tr("Table print options ..."));
|
||||
QGridLayout* lay=new QGridLayout();
|
||||
dlg->setLayout(lay);
|
||||
lay->addWidget(new QLabel(tr("<b>scaling:</b>")), 0,0);
|
||||
QCheckBox* chk1Wide=new QCheckBox(tr("one page wide"), dlg);
|
||||
QCheckBox* chk1High=new QCheckBox(tr("one page high"), dlg);
|
||||
lay->addWidget(chk1Wide, 0, 1);
|
||||
lay->addWidget(chk1High, 1, 1);
|
||||
|
||||
QDialogButtonBox* btns=new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel,Qt::Horizontal,dlg);
|
||||
connect(btns, SIGNAL(accepted()), dlg, SLOT(accept()));
|
||||
connect(btns, SIGNAL(rejected()), dlg, SLOT(reject()));
|
||||
lay->addWidget(btns, 2, 0,1,2);
|
||||
|
||||
if (dlg->exec()) {
|
||||
print(tablePrinter, chk1Wide->isChecked(), chk1High->isChecked());
|
||||
}
|
||||
delete dlg;
|
||||
delete tablePrinter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JKQTPEnhancedTableView::print(QPrinter *printer, bool onePageWide, bool onePageHigh)
|
||||
{
|
||||
QPrinter* p=printer;
|
||||
|
||||
|
||||
//p->setPageMargins(10,10,10,10,QPrinter::Millimeter);
|
||||
|
||||
/*if (width()>height()) {
|
||||
p->setOrientation(QPrinter::Landscape);
|
||||
} else {
|
||||
p->setOrientation(QPrinter::Portrait);
|
||||
}*/
|
||||
|
||||
clearSelection();
|
||||
|
||||
|
||||
/// PRINT HERE //////////////////////////////////////////////////////////////////////////////////
|
||||
// calculate the total width/height table would need without scaling
|
||||
const int rows = model()->rowCount();
|
||||
const int cols = model()->columnCount();
|
||||
double vhw=verticalHeader()->width()+8;
|
||||
double totalWidth = vhw;
|
||||
double minWidth=1e33;
|
||||
double maxWidth=0;
|
||||
for (int c = -1; c < cols; ++c)
|
||||
{
|
||||
double w=columnWidth(c);
|
||||
totalWidth += w;
|
||||
if (w<minWidth) minWidth=w;
|
||||
if (w>maxWidth) maxWidth=w;
|
||||
}
|
||||
double hhh=horizontalHeader()->height()+8;
|
||||
double totalHeight = hhh;
|
||||
double minHeight=1e33;
|
||||
double maxHeight=0;
|
||||
for (int r = 0; r < rows; ++r)
|
||||
{
|
||||
double h=rowHeight(r);
|
||||
totalHeight += h;
|
||||
if (h<minHeight) minHeight=h;
|
||||
if (h>maxHeight) maxHeight=h;
|
||||
}
|
||||
double scale=1.0;
|
||||
// adjust scale, so the widest/highest column fits on one page
|
||||
/*if (maxWidth*scale>p->pageRect().width()) scale=p->pageRect().width()/maxWidth;
|
||||
if (maxHeight*scale>p->pageRect().height()) scale=p->pageRect().height()/maxHeight;*/
|
||||
if (onePageWide) {
|
||||
if (totalWidth>p->pageRect().width()) scale=p->pageRect().width()/totalWidth;
|
||||
}
|
||||
if (onePageHigh) {
|
||||
if (totalHeight>p->pageRect().height()) scale=qMin(scale, p->pageRect().height()/totalHeight);
|
||||
}
|
||||
|
||||
//qDebug()<<scale;
|
||||
|
||||
// print scaled pixmap
|
||||
|
||||
int pagesWide=1;
|
||||
int pagesHigh=1;
|
||||
QList<int> pageCols, pageRows;
|
||||
pageCols<<0;
|
||||
pageRows<<0;
|
||||
{ // find number of pages needed
|
||||
double x=vhw, x0=vhw;
|
||||
if (!onePageWide) {
|
||||
for (int c=0; c<cols; c++) {
|
||||
double cw=columnWidth(c);
|
||||
if (x+cw>p->pageRect().width()/scale) {
|
||||
pagesWide++;
|
||||
x=0;
|
||||
pageCols<<c;
|
||||
} else {
|
||||
x=x+cw;
|
||||
x0=x0+cw;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pageCols.size()>0 && cols>pageCols.last()) pageCols<<cols;
|
||||
if (pageCols.size()==1) pageCols<<cols;
|
||||
double y=hhh, y0=hhh;
|
||||
if (!onePageHigh) {
|
||||
for (int r=0; r<rows; r++) {
|
||||
double rh=rowHeight(r);
|
||||
if (y+rh>p->pageRect().height()/scale) {
|
||||
pagesHigh++;
|
||||
pageRows<<r;
|
||||
y=hhh;
|
||||
} else {
|
||||
y=y+rh;
|
||||
y0=y0+rh;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pageRows.size()>0 && rows>pageRows.last()) pageRows<<rows;
|
||||
if (pageRows.size()==1) pageRows<<rows;
|
||||
}
|
||||
|
||||
JKQTPEnhancedPainter painter(p);
|
||||
paint(painter, scale, -1, hhh, vhw, pageCols, pageRows, p);
|
||||
painter.end();
|
||||
|
||||
|
||||
|
||||
|
||||
/// PRINT DONE //////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
void JKQTPEnhancedTableView::paint(QPainter &painter, QRect pageRect)
|
||||
{
|
||||
QRect pageRec=pageRect;
|
||||
if (pageRec.width()==0 || pageRec.height()==0) pageRec=QRect(QPoint(0,0), getTotalSize().toSize());
|
||||
painter.save();
|
||||
painter.translate(pageRec.topLeft());
|
||||
QSizeF size=getTotalSize();
|
||||
double vhw=verticalHeader()->width()+8;
|
||||
double hhh=horizontalHeader()->height()+8;
|
||||
double scaleX=size.width()/double(pageRec.width());
|
||||
double scaleY=size.height()/double(pageRec.height());
|
||||
double scale=qMin(scaleX, scaleY);
|
||||
QList<int>pageCols, pageRows;
|
||||
pageCols<<0<<model()->columnCount();
|
||||
pageRows<<0<<model()->rowCount();
|
||||
paint(painter, scale, -1, hhh, vhw, pageCols, pageRows);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
QSizeF JKQTPEnhancedTableView::getTotalSize() const
|
||||
{
|
||||
const int rows = model()->rowCount();
|
||||
const int cols = model()->columnCount();
|
||||
double vhw=verticalHeader()->width()+8;
|
||||
double totalWidth = vhw;
|
||||
for (int c = -1; c < cols; ++c)
|
||||
{
|
||||
double w=columnWidth(c);
|
||||
totalWidth += w;
|
||||
}
|
||||
double hhh=horizontalHeader()->height()+8;
|
||||
double totalHeight = hhh;
|
||||
for (int r = 0; r < rows; ++r)
|
||||
{
|
||||
double h=rowHeight(r);
|
||||
totalHeight += h;
|
||||
}
|
||||
|
||||
return QSizeF((totalWidth), (totalHeight));
|
||||
}
|
||||
|
||||
void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p)
|
||||
{
|
||||
painter.save();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
painter.scale(scale, scale);
|
||||
QPen headerPen("black");
|
||||
headerPen.setWidth(2);
|
||||
QPen cellPen("gray");
|
||||
cellPen.setWidth(1);
|
||||
QFont headerFont=horizontalHeader()->font();
|
||||
headerFont.setBold(true);
|
||||
int pagesWide=pageCols.size()-1;
|
||||
int pagesHigh=pageRows.size()-1;
|
||||
//painter.translate(p->pageRect().topLeft());
|
||||
int pageCnt=0;
|
||||
for (int ph=0; ph<pageRows.size()-1; ph++) {
|
||||
for (int pw=0; pw<pageCols.size()-1; pw++) {
|
||||
if (page<0 || page==pageCnt) {
|
||||
//qDebug()<<"print page "<<ph<<"/"<<pageRows.size()<<pagesHigh<<" "<<pw<<"/"<<pageCols.size()<<pagesWide;
|
||||
//painter.drawPicture(p->pageRect().topLeft(), pic);
|
||||
double y=0;
|
||||
if (ph==0) {
|
||||
y=hhh;
|
||||
}
|
||||
//qDebug()<<" rows = "<<pageRows[ph]<<"..."<<pageRows[ph+1]-1;
|
||||
//qDebug()<<" cols = "<<pageCols[pw]<<"..."<<pageCols[pw+1]-1;
|
||||
for (int r=pageRows[ph]; r<pageRows[ph+1]; r++) {
|
||||
double x=0;
|
||||
int rh=rowHeight(r);
|
||||
if (pw%pagesWide==0) {
|
||||
x=0;
|
||||
option.rect = QRect((int)x, (int)y, (int)vhw, rh);
|
||||
//verticalHeader()->itemDelegate()->paint(&painter, option, model()->index(r, c, QModelIndex()));
|
||||
x=vhw;
|
||||
}
|
||||
for (int c=pageCols[pw]; c<pageCols[pw+1]; c++) {
|
||||
double cw=columnWidth(c);
|
||||
option.rect = QRect((int)x, (int)y, (int)cw, rh);
|
||||
itemDelegate()->paint(&painter, option, model()->index(r, c, QModelIndex()));
|
||||
painter.setPen(cellPen);
|
||||
painter.drawRect(option.rect);
|
||||
x=x+cw;
|
||||
|
||||
}
|
||||
y=y+rh;
|
||||
}
|
||||
|
||||
if (ph==0) {
|
||||
y=0;
|
||||
int x=0;
|
||||
if (pw%pagesWide==0) x=(int)vhw;
|
||||
painter.setPen(headerPen);
|
||||
for (int c=pageCols[pw]; c<pageCols[pw+1]; c++) {
|
||||
QRect rec=QRect(x, (int)y, columnWidth(c), (int)hhh);
|
||||
painter.fillRect(rec, QColor("lightgrey"));
|
||||
painter.setFont(headerFont);
|
||||
painter.setPen(headerPen);
|
||||
painter.drawText(QRect(rec.x()+4, rec.y()+4, rec.width()-8, rec.height()-8), model()->headerData(c, Qt::Horizontal).toString());
|
||||
painter.drawRect(rec);
|
||||
//if (x==vhw &&) painter.drawLine(rec.topLeft(), QPoint(rec.left(), p->pageRect().height()));
|
||||
x=x+columnWidth(c);
|
||||
}
|
||||
|
||||
}
|
||||
if (pw%pagesWide==0) {
|
||||
y=0;
|
||||
int x=0;
|
||||
if (ph==0) y=hhh;
|
||||
for (int r=pageRows[ph]; r<pageRows[ph+1]; r++) {
|
||||
QRect rec=QRect(x, (int)y, (int)vhw, rowHeight(r));
|
||||
painter.fillRect(rec, QColor("lightgrey"));
|
||||
painter.setPen(headerPen);
|
||||
painter.setFont(headerFont);
|
||||
painter.drawText(QRect(rec.x()+4, rec.y()+4, rec.width()-8, rec.height()-8), model()->headerData(r, Qt::Vertical).toString());
|
||||
painter.drawRect(rec);
|
||||
//if (x==vhw &&) painter.drawLine(rec.topLeft(), QPoint(rec.left(), p->pageRect().height()));
|
||||
y=y+rowHeight(r);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (p && pw<pagesWide-1) p->newPage();
|
||||
}
|
||||
pageCnt++;
|
||||
}
|
||||
if (p && ph<pagesHigh-1) p->newPage();
|
||||
}
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
QPrinter *JKQTPEnhancedTableView::getPrinter(QPrinter *printerIn, bool *localPrinter)
|
||||
{
|
||||
QPrinter* p=printerIn;
|
||||
if (p==nullptr) {
|
||||
p=new QPrinter();
|
||||
if (localPrinter) *localPrinter=true;
|
||||
}
|
||||
|
||||
QPrintDialog *dialog = new QPrintDialog(p, nullptr);
|
||||
dialog->setWindowTitle(tr("Print Table"));
|
||||
if (dialog->exec() != QDialog::Accepted) {
|
||||
if (localPrinter && *localPrinter) delete p;
|
||||
delete dialog;
|
||||
return printerIn;
|
||||
}
|
||||
p=dialog->printer();
|
||||
delete dialog;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
78
lib/jkqtplottergui/jkqtpenhancedtableview.h
Normal file
78
lib/jkqtplottergui/jkqtpenhancedtableview.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
This software is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtptools Tool Functions and Definitions
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
/** \file jkqtptools.h
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JKQTPEnhancedTableView_H_INCLUDED
|
||||
#define JKQTPEnhancedTableView_H_INCLUDED
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include <QTableView>
|
||||
#include <QPrinter>
|
||||
|
||||
/*! \brief this class extends the QTableView
|
||||
\ingroup jkqtptools
|
||||
|
||||
This enhanced table view adds some functionality to the Qt class:
|
||||
- return HTML code that describes the table
|
||||
- the selected cells may be copied to Excel using the clipboard (Excel will recognize number !)
|
||||
.
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPEnhancedTableView(QWidget* parent=nullptr);
|
||||
virtual ~JKQTPEnhancedTableView();
|
||||
|
||||
/** \brief return the contents of the table view as HTML fragment */
|
||||
QString toHtml(int borderWidth=1, bool non_breaking=false, int fontSizePt=-1) const;
|
||||
void print(QPrinter* printer, bool onePageWide=false, bool onePageHigh=false);
|
||||
|
||||
void paint(QPainter& painter, QRect pageRec=QRect());
|
||||
QSizeF getTotalSize() const;
|
||||
QAction* getPrintAction() const { return printAction; }
|
||||
|
||||
signals:
|
||||
void keyPressed(int key, Qt::KeyboardModifiers modifiers, QString text);
|
||||
public slots:
|
||||
void copySelectionToExcel(int copyrole=Qt::EditRole, bool storeHead=true);
|
||||
void copySelectionToExcelNoHead(int copyrole=Qt::EditRole);
|
||||
void copySelectionToCSV(int copyrole=Qt::EditRole, bool storeHead=true, const QString& separator=", ", const QChar& decimalpoint='.');
|
||||
void copySelectionToCSVNoHead(int copyrole=Qt::EditRole, const QString& separator=", ", const QChar& decimalpoint='.');
|
||||
void print();
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent* event);
|
||||
void paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p=nullptr);
|
||||
|
||||
QPrinter* getPrinter(QPrinter* printerIn=nullptr, bool *localPrinter=nullptr);
|
||||
QAction* printAction;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // JKQTPEnhancedTableView_H_INCLUDED
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
@ -19,34 +19,34 @@
|
||||
|
||||
|
||||
|
||||
/** \file jkqtpplotsmodel.cpp
|
||||
/** \file jkqtpgraphsmodel.cpp
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include <QImage>
|
||||
|
||||
|
||||
|
||||
JKQTPPlotsModel::JKQTPPlotsModel(JKQtBasePlotter *parent):
|
||||
JKQTPgraphsModel::JKQTPgraphsModel(JKQtBasePlotter *parent):
|
||||
QAbstractTableModel(parent), m_plotter(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int JKQTPPlotsModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
int JKQTPgraphsModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return static_cast<int>(m_plotter->getGraphCount());
|
||||
}
|
||||
|
||||
int JKQTPPlotsModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
int JKQTPgraphsModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant JKQTPPlotsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant JKQTPgraphsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (index.row()<static_cast<int>(m_plotter->getGraphCount())) return m_plotter->getGraph(static_cast<size_t>(index.row()))->get_title();
|
||||
@ -60,7 +60,7 @@ QVariant JKQTPPlotsModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool JKQTPPlotsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
bool JKQTPgraphsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (role == Qt::CheckStateRole) {
|
||||
if (index.row()<static_cast<int>(m_plotter->getGraphCount())) {
|
||||
@ -71,12 +71,12 @@ bool JKQTPPlotsModel::setData(const QModelIndex &index, const QVariant &value, i
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::ItemFlags JKQTPPlotsModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags JKQTPgraphsModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return Qt::ItemIsUserCheckable | QAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
void JKQTPPlotsModel::plotUpdated()
|
||||
void JKQTPgraphsModel::plotUpdated()
|
||||
{
|
||||
beginResetModel();
|
||||
endResetModel();
|
@ -20,18 +20,18 @@
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtpplotsmodel data model with all plots ina JKQtBasePlotter (+ allows to switch them visible/invisible)
|
||||
* \defgroup jkqtpgraphsmodel data model with all plots ina JKQtBasePlotter (+ allows to switch them visible/invisible)
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file jkqtpplotsmodel.h
|
||||
/** \file jkqtpgraphsmodel.h
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#ifndef JKQTPPLOTSMODEL_H
|
||||
#define JKQTPPLOTSMODEL_H
|
||||
#ifndef jkqtpgraphsmodel_H
|
||||
#define jkqtpgraphsmodel_H
|
||||
|
||||
#include "jkqtplotter/jkqtpbaseplotter.h"
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
@ -40,11 +40,11 @@
|
||||
|
||||
class JKQtBasePlotter; // forward
|
||||
/** \brief data model with all plots ina JKQtBasePlotter (+ allows to switch them visible/invisible) */
|
||||
class JKQTPPlotsModel : public QAbstractTableModel
|
||||
class JKQTPgraphsModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPPlotsModel(JKQtBasePlotter *parent);
|
||||
JKQTPgraphsModel(JKQtBasePlotter *parent);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override ;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
@ -57,4 +57,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // JKQTPPLOTSMODEL_H
|
||||
#endif // jkqtpgraphsmodel_H
|
38
lib/jkqtplottergui/jkvanishqtoolbar.cpp
Normal file
38
lib/jkqtplottergui/jkvanishqtoolbar.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** \file jkvanishqtoolbar.cpp
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#include "jkqtplottergui/jkvanishqtoolbar.h"
|
||||
|
||||
JKVanishQToolBar::JKVanishQToolBar(const QString &title, QWidget *parent): QToolBar(title, parent) {
|
||||
toolbarVanishes=true;
|
||||
}
|
||||
|
||||
JKVanishQToolBar::JKVanishQToolBar(QWidget *parent): QToolBar(parent){
|
||||
toolbarVanishes=true;
|
||||
}
|
||||
|
||||
void JKVanishQToolBar::leaveEvent(QEvent *) {
|
||||
if (toolbarVanishes) hide();
|
||||
}
|
48
lib/jkqtplottergui/jkvanishqtoolbar.h
Normal file
48
lib/jkqtplottergui/jkvanishqtoolbar.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** \file jkvanishqtoolbar.h
|
||||
* \ingroup jkqtpbaseplotter
|
||||
*/
|
||||
|
||||
#ifndef jkvanishqtoolbar_H
|
||||
#define jkvanishqtoolbar_H
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include <QToolBar>
|
||||
|
||||
/** \brief a modified a href="http://doc.trolltech.com/4.5/qtoolbar.html">QToolBar</a> which vanishes when the mouse leaves the toolbar.
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKVanishQToolBar: public QToolBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
JKVanishQToolBar(const QString& title, QWidget* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
JKVanishQToolBar(QWidget* parent=nullptr);
|
||||
JKQTPGET_SET_MACRO(bool, toolbarVanishes)
|
||||
protected:
|
||||
bool toolbarVanishes;
|
||||
/** \brief this event triggers the vanishing of the toolbar */
|
||||
void leaveEvent ( QEvent * /*event*/ );
|
||||
};
|
||||
#endif // jkvanishqtoolbar_H
|
260
lib/jkqtplottertools/jkqtpdrawingtools.cpp
Normal file
260
lib/jkqtplottertools/jkqtpdrawingtools.cpp
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** \file jkqtpdrawingtools.cpp
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
#include "jkqtplottertools/jkqtpdrawingtools.h"
|
||||
#include "jkqtplottertools/jkqtpenhancedpainter.h"
|
||||
|
||||
|
||||
|
||||
void JKQTPplotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor) {
|
||||
JKQTPEnhancedPainter p(&paintDevice);
|
||||
JKQTPplotSymbol(p, x, y, symbol, size, symbolLineWidth, color, fillColor);
|
||||
}
|
||||
|
||||
void JKQTPplotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSymbols symbol, double symbolSize, double symbolLineWidth, QColor color, QColor fillColor) {
|
||||
painter.save();
|
||||
QPen p=painter.pen();
|
||||
p.setColor(color);
|
||||
p.setWidthF(qMax(JKQTPLOTTER_ABS_MIN_LINEWIDTH, symbolLineWidth));
|
||||
p.setStyle(Qt::SolidLine);
|
||||
painter.setPen(p);
|
||||
QBrush b=painter.brush();
|
||||
b.setColor(fillColor);
|
||||
b.setStyle(Qt::SolidPattern);
|
||||
const double w=symbolSize;
|
||||
const double w2=w/2.0;
|
||||
const double w3=w/3.0;
|
||||
|
||||
// calculate star cordinates as static values
|
||||
static int star_items=0;
|
||||
static double starcordsx[10];
|
||||
static double starcordsy[10];
|
||||
if (star_items==0) {
|
||||
star_items=5;
|
||||
double angle=360.0/double(star_items)/180.0*M_PI;
|
||||
for (int i=0; i<star_items; i++) {
|
||||
double a=((double)i+0.5)*angle;
|
||||
starcordsx[i*2]=sin(a);
|
||||
starcordsx[i*2+1]=0.5*sin(a+angle/2.0);
|
||||
starcordsy[i*2]=cos(a);
|
||||
starcordsy[i*2+1]=0.5*cos(a+angle/2.0);
|
||||
}
|
||||
}
|
||||
|
||||
switch(symbol) {
|
||||
case JKQTPdot:
|
||||
painter.drawPoint(QPointF(x,y));
|
||||
break;
|
||||
case JKQTPcross:{
|
||||
/*QVector<QLineF> lines;
|
||||
lines<<QLineF(x-w2,y-w2,x+w2,y+w2);
|
||||
lines<<QLineF(x-w2,y+w2,x+w2,y-w2);
|
||||
painter.drawLines(lines);*/
|
||||
QPainterPath path;
|
||||
path.moveTo(x-w2,y-w2);
|
||||
path.lineTo(x+w2,y+w2);
|
||||
path.moveTo(x-w2,y+w2);
|
||||
path.lineTo(x+w2,y-w2);
|
||||
painter.drawPath(path);
|
||||
}
|
||||
break;
|
||||
case JKQTPplus:{
|
||||
QVector<QLineF> lines;
|
||||
lines<<QLineF(x,y-w2,x,y+w2);
|
||||
lines<<QLineF(x-w2,y,x+w2,y);
|
||||
painter.drawLines(lines);
|
||||
}
|
||||
break;
|
||||
case JKQTPcircle:{
|
||||
QRectF rectangle(x-w2, y-w2, w, w);
|
||||
painter.drawEllipse(rectangle);
|
||||
}
|
||||
break;
|
||||
case JKQTPtarget:{
|
||||
QPainterPath path;
|
||||
QRectF rectangle3(x-w3, y-w3, 2.0*w3, 2.0*w3);
|
||||
path.addEllipse(rectangle3);
|
||||
path.moveTo(QPointF(x,y-w2));
|
||||
path.lineTo(QPointF(x,y+w2));
|
||||
path.moveTo(QPointF(x-w2,y));
|
||||
path.lineTo(QPointF(x+w2,y));
|
||||
painter.drawPath(path);
|
||||
}
|
||||
break;
|
||||
case JKQTPfilledCircle:{
|
||||
painter.setBrush(b);
|
||||
QRectF rectangle(x-w2, y-w2, w, w);
|
||||
painter.drawEllipse(rectangle);
|
||||
}
|
||||
break;
|
||||
case JKQTPrect:{
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
QRectF rectangle(x-w2, y-w2, w, w);
|
||||
painter.drawRect(rectangle);
|
||||
}
|
||||
break;
|
||||
case JKQTPrectCross:{
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
QPainterPath path;
|
||||
path.moveTo(x-w2,y-w2);
|
||||
path.lineTo(x+w2,y+w2);
|
||||
path.moveTo(x-w2,y+w2);
|
||||
path.lineTo(x+w2,y-w2);
|
||||
painter.drawPath(path);
|
||||
QRectF rectangle(x-w2, y-w2, w, w);
|
||||
painter.drawRect(rectangle);
|
||||
}
|
||||
break;
|
||||
case JKQTPrectPlus:{
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
QVector<QLineF> lines;
|
||||
lines<<QLineF(x,y-w2,x,y+w2);
|
||||
lines<<QLineF(x-w2,y,x+w2,y);
|
||||
painter.drawLines(lines);
|
||||
QRectF rectangle(x-w2, y-w2, w, w);
|
||||
painter.drawRect(rectangle);
|
||||
}
|
||||
break;
|
||||
case JKQTPfilledRect:{
|
||||
painter.setBrush(b);
|
||||
QRectF rectangle(x-w2, y-w2, w, w);
|
||||
painter.drawRect(rectangle);
|
||||
}
|
||||
break;
|
||||
case JKQTPtriangle: {
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(x-w2, y+w2)<<QPointF(x+w2, y+w2)<<QPointF(x, y-w2);
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPfilledTriangle: {
|
||||
painter.setBrush(b);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(x-w2, y+w2)<<QPointF(x+w2, y+w2)<<QPointF(x, y-w2);
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPdownTriangle: {
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(x-w2, y-w2)<<QPointF(x+w2, y-w2)<<QPointF(x, y+w2);
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPfilledDownTriangle: {
|
||||
painter.setBrush(b);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(x-w2, y-w2)<<QPointF(x+w2, y-w2)<<QPointF(x, y+w2);
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPdiamond: {
|
||||
QPolygonF poly;
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
poly<<QPointF(x, y-w2)<<QPointF(x+w2, y)<<QPointF(x, y+w2)<<QPointF(x-w2, y);
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPfilledDiamond: {
|
||||
painter.setBrush(b);
|
||||
QPolygonF poly;
|
||||
poly<<QPointF(x, y-w2)<<QPointF(x+w2, y)<<QPointF(x, y+w2)<<QPointF(x-w2, y);
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPstar: {
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
QPolygonF poly;
|
||||
for (int i=0; i<star_items*2; i++) {
|
||||
poly<<QPointF(x+starcordsx[i]*w2, y+starcordsy[i]*w2);
|
||||
}
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPfilledStar: {
|
||||
painter.setBrush(b);
|
||||
QPolygonF poly;
|
||||
for (int i=0; i<star_items*2; i++) {
|
||||
poly<<QPointF(x+starcordsx[i]*w2, y+starcordsy[i]*w2);
|
||||
}
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPpentagon: {
|
||||
painter.setBrush(QColor(Qt::transparent));
|
||||
QPolygonF poly;
|
||||
for (int i=0; i<star_items*2; i+=2) {
|
||||
poly<<QPointF(x+starcordsx[i]*w2, y+starcordsy[i]*w2);
|
||||
}
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
case JKQTPasterisc: {
|
||||
//QVector<QLineF> lines;
|
||||
QPainterPath path;
|
||||
for (int i=0; i<star_items*2; i+=2) {
|
||||
//lines<<QLineF(x+starcordsx[i]*w2, y+starcordsy[i]*w2, x, y);
|
||||
path.moveTo(x+starcordsx[i]*w2, y+starcordsy[i]*w2);
|
||||
path.lineTo(x,y);
|
||||
}
|
||||
//painter.drawLines(lines);
|
||||
painter.drawPath(path);
|
||||
} break;
|
||||
case JKQTPfilledPentagon: {
|
||||
painter.setBrush(b);
|
||||
QPolygonF poly;
|
||||
for (int i=0; i<star_items*2; i+=2) {
|
||||
poly<<QPointF(x+starcordsx[i]*w2, y+starcordsy[i]*w2);
|
||||
}
|
||||
painter.drawConvexPolygon(poly);
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
painter.restore();
|
||||
};
|
||||
|
||||
|
||||
|
||||
QVector<QPointF> JKQTPdrawEllipse(double x, double y, double a, double b, double angle_start, double angle_end, double alpha, int controlPoints, QPointF* x_start, QPointF* x_end) {
|
||||
QVector<QPointF> result;
|
||||
double start=angle_start*M_PI/180.0;
|
||||
double stop=angle_end*M_PI/180.0;
|
||||
double step=(stop-start)/(double)controlPoints;
|
||||
while (fabs(stop-start)/step<10) step=step/2.0;
|
||||
double sina=sin(1.0*alpha/180.0*M_PI);
|
||||
double cosa=cos(1.0*alpha/180.0*M_PI);
|
||||
QPointF xp(x+a*cos(start)*cosa-b*sin(start)*sina, y+a*cos(start)*sina+b*sin(start)*cosa);
|
||||
result.append(xp);
|
||||
if (x_start) *x_start = xp;
|
||||
double t=start+step;
|
||||
for (int i=1; i<controlPoints; i++) {
|
||||
double cost=cos(t);
|
||||
double sint=sin(t);
|
||||
xp=QPointF( x+a*cost*cosa-b*sint*sina, y+a*cost*sina+b*sint*cosa);
|
||||
result.append(xp);
|
||||
//std::cout<<"t="<<t/M_PI*180.0<<": sin(al)="<<sina<<" cos(al)="<<cosa<<" sin(t)="<<sint<<" cos(t)="<<cost<<" a="<<a<<" b="<<b<<": ("<<x+a*cost*cosa-b*sint*sina<<", "<<y+a*cost*sina+b*sint*cosa<<") = ("<<xp.x()<<", "<<xp.y()<<") \n";
|
||||
t=t+step;
|
||||
}
|
||||
if (x_end) *x_end=xp;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
105
lib/jkqtplottertools/jkqtpdrawingtools.h
Normal file
105
lib/jkqtplottertools/jkqtpdrawingtools.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
This software is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtptools Tool Functions and Definitions
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
/** \file jkqtptools.h
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JKQTPDRAWINGTOOLS_H_INCLUDED
|
||||
#define JKQTPDRAWINGTOOLS_H_INCLUDED
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include <QPaintDevice>
|
||||
|
||||
class JKQTPEnhancedPainter; // forward
|
||||
|
||||
/*! \brief plot the specified symbol at pixel position x,y
|
||||
\ingroup jkqtptools
|
||||
|
||||
\param painter the QPainter to draw to
|
||||
\param x x-coordinate of the symbol center
|
||||
\param y y-coordinate of the symbol center
|
||||
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
|
||||
\param size size (width/height) of the symbol around (\a x , \a y)
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
*/
|
||||
LIB_EXPORT void JKQTPplotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
|
||||
/*! \brief plot the specified symbol at pixel position x,y
|
||||
\ingroup jkqtptools
|
||||
|
||||
\param paintDevice the paint device to draw on
|
||||
\param x x-coordinate of the symbol center
|
||||
\param y y-coordinate of the symbol center
|
||||
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
|
||||
\param size size (width/height) of the symbol around (\a x , \a y)
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
*/
|
||||
LIB_EXPORT void JKQTPplotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
|
||||
|
||||
/*! \brief plot an arrow between positions (x1,y1) and (x2,y2)
|
||||
\ingroup jkqtptools
|
||||
|
||||
\param painter the QPainter to draw to
|
||||
\param x1 first x-coordinate of the arrow
|
||||
\param y1 first y-coordinate of the arrow
|
||||
\param x2 second x-coordinate of the arrow
|
||||
\param y2 second y-coordinate of the arrow
|
||||
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
|
||||
\param size size (width/height) of the symbol around (\a x , \a y)
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
*/
|
||||
//LIB_EXPORT void JKQTPplotArrow(JKQTPEnhancedPainter& painter, int x, int y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
|
||||
|
||||
/*! \brief draw an ellipse without setting pen or brush, or saving the painter!
|
||||
\ingroup jkqtptools
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param x center of ellipse (x-coordinate)
|
||||
\param y center of ellipse (y-coordinate)
|
||||
\param a half axis in x-direction
|
||||
\param b half axis in y-direction
|
||||
\param angle_start starting angle of ellipse section
|
||||
\param angle_end ending angle of ellipse section
|
||||
\param alpha rotation angle of ellipse
|
||||
\param controlPoints the number of points to use for drawing
|
||||
\param[out] x_start first point of ellipse
|
||||
\param[out] x_end last point of ellipse
|
||||
|
||||
\note all angles are given in degrees [0..360]
|
||||
*/
|
||||
LIB_EXPORT QVector<QPointF> JKQTPdrawEllipse(double x, double y, double a, double b, double angle_start=0, double angle_end=360, double alpha=0, int controlPoints=180, QPointF* x_start=nullptr, QPointF* x_end=nullptr);
|
||||
|
||||
|
||||
#endif // JKQTPDRAWINGTOOLS_H_INCLUDED
|
75
lib/jkqtplottertools/jkqtpenhancedpainter.cpp
Normal file
75
lib/jkqtplottertools/jkqtpenhancedpainter.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 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 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** \file jkqtptools.cpp
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
#include "jkqtplottertools/jkqtpenhancedpainter.h"
|
||||
|
||||
|
||||
|
||||
JKQTPEnhancedPainter::JKQTPEnhancedPainter(QPaintDevice *device):
|
||||
QPainter(device)
|
||||
{
|
||||
initQEnhacedPainter();
|
||||
}
|
||||
|
||||
JKQTPEnhancedPainter::JKQTPEnhancedPainter():
|
||||
QPainter()
|
||||
{
|
||||
initQEnhacedPainter();
|
||||
}
|
||||
|
||||
JKQTPEnhancedPainter::~JKQTPEnhancedPainter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//void JKQTPEnhancedPainter::drawLines(const QLineF *lines, int lineCount)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//void JKQTPEnhancedPainter::drawLines(const QPointF *lines, int lineCount)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//void JKQTPEnhancedPainter::drawLines(const QLine *lines, int lineCount)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//void JKQTPEnhancedPainter::drawLines(const QPoint *lines, int lineCount)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
|
||||
void JKQTPEnhancedPainter::initQEnhacedPainter()
|
||||
{
|
||||
|
||||
}
|
151
lib/jkqtplottertools/jkqtpenhancedpainter.h
Normal file
151
lib/jkqtplottertools/jkqtpenhancedpainter.h
Normal file
@ -0,0 +1,151 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
This software is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup jkqtptools Tool Functions and Definitions
|
||||
* \ingroup jkqtplotter
|
||||
*/
|
||||
|
||||
/** \file jkqtptools.h
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JKQTPENHANCED_PAINTERS_H
|
||||
#define JKQTPENHANCED_PAINTERS_H
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
|
||||
/*! \brief this class extends the QPainter
|
||||
\ingroup jkqtptools
|
||||
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedPainter : public QPainter {
|
||||
public:
|
||||
JKQTPEnhancedPainter(QPaintDevice* device);
|
||||
JKQTPEnhancedPainter();
|
||||
virtual ~JKQTPEnhancedPainter();
|
||||
|
||||
|
||||
//void drawPath(const QPainterPath &path);
|
||||
//void drawPoints(const QPoint *points, int pointCount);
|
||||
//void drawPoints(const QPointF *points, int pointCount);
|
||||
// void drawLines(const QLineF *lines, int lineCount);
|
||||
// void drawLines(const QPointF *pointPairs, int lineCount);
|
||||
// void drawLines(const QLine *lines, int lineCount);
|
||||
// void drawLines(const QPoint *pointPairs, int lineCount);
|
||||
|
||||
|
||||
// inline void drawPoint(const QPointF &p) {
|
||||
// drawPoints(&p, 1);
|
||||
// }
|
||||
|
||||
// inline void drawPoint(const QPoint &p) {
|
||||
// drawPoints(&p, 1);
|
||||
// }
|
||||
|
||||
// inline void drawPoint(int x, int y) {
|
||||
// drawPoint(QPointF(x,y));
|
||||
// }
|
||||
|
||||
// inline void drawPoint(double x, double y) {
|
||||
// drawPoint(QPointF(x,y));
|
||||
// }
|
||||
|
||||
// inline void drawPoints(const QPolygonF &points){
|
||||
// drawPoints(points.constData(), points.size());
|
||||
// }
|
||||
|
||||
// inline void drawPoints(const QPolygon &points){
|
||||
// drawPoints(points.constData(), points.size());
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QLineF &line) {
|
||||
// drawLines(&l, 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QLine &line) {
|
||||
// drawLines(&l, 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(int x1, int y1, int x2, int y2) {
|
||||
// drawLines(QLineF(x1,y1,x2,y2), 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(double x1, double y1, double x2, double y2) {
|
||||
// drawLines(QLineF(x1,y1,x2,y2), 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QPoint &p1, const QPoint &p2) {
|
||||
// drawLine(QLineF(QLine(p1, p2)));
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QPointF &p1, const QPointF &p2) {
|
||||
// drawLine(QLineF(p1, p2));
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QLineF> &lines) {
|
||||
// drawLines(lines.constData(), lines.size());
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QPointF> &pointPairs) {
|
||||
// drawLines(pointPairs.constData(), pointPairs.size() / 2);
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QLine> &lines) {
|
||||
// drawLines(lines.constData(), lines.size());
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QPoint> &pointPairs) {
|
||||
// drawLines(pointPairs.constData(), pointPairs.size() / 2);
|
||||
// }
|
||||
|
||||
// inline void drawRect(const QRectF &rect) {
|
||||
// drawRects(&rect, 1);
|
||||
// }
|
||||
|
||||
// inline void drawRect(int x1, int y1, int w, int h) {
|
||||
// QRectF r(x, y, w, h);
|
||||
// drawRects(&r, 1);
|
||||
// }
|
||||
|
||||
// inline void drawRect(double x1, double y1, double w, double h) {
|
||||
// QRectF r(x, y, w, h);
|
||||
// drawRects(&r, 1);
|
||||
// }
|
||||
|
||||
// inline void drawRect(const QRect &rect) {
|
||||
// drawRects(&r, 1);
|
||||
// }
|
||||
|
||||
protected:
|
||||
virtual void initQEnhacedPainter();
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // JKQTPENHANCED_PAINTERS_H
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center (DKFZ) & IWR, University of Heidelberg
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>) (DKFZ) & IWR, University of Heidelberg
|
||||
|
||||
last modification: $LastChangedDate: 2015-06-10 19:19:10 +0200 (Mi, 10 Jun 2015) $ (revision $Rev: 3976 $)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center (DKFZ) & IWR, University of Heidelberg
|
||||
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>) (DKFZ) & IWR, University of Heidelberg
|
||||
|
||||
last modification: $LastChangedDate: 2015-06-10 19:19:10 +0200 (Mi, 10 Jun 2015) $ (revision $Rev: 3976 $)
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
|
||||
#include "jkqtplotter/jkqtpimagetools.h"
|
||||
#include "jkqtplottertools/jkqtpimagetools.h"
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
@ -32,8 +32,8 @@
|
||||
# include <QtXml/QtXml>
|
||||
#endif
|
||||
|
||||
#define PALETTE_ICON_WIDTH 64
|
||||
#define PALETTE_IMAGEICON_HEIGHT 64
|
||||
#define JKQTP_PALETTE_ICON_WIDTH 64
|
||||
#define JKQTP_PALETTE_IMAGEICON_HEIGHT 64
|
||||
|
||||
QList<int*> global_jkqtpimagetools_lutstore = QList<int*>();
|
||||
|
||||
@ -1759,9 +1759,9 @@ QImage JKQTPMathImageGetPaletteImage(int *lut, int lut_size, int width)
|
||||
|
||||
|
||||
QIcon JKQTPMathImageGetPaletteIcon(int i) {
|
||||
QImage img=JKQTPMathImageGetPaletteImage(i, PALETTE_ICON_WIDTH);
|
||||
QPixmap pix(PALETTE_ICON_WIDTH,8);
|
||||
QRect r(0,0,PALETTE_ICON_WIDTH-1,7);
|
||||
QImage img=JKQTPMathImageGetPaletteImage(i, JKQTP_PALETTE_ICON_WIDTH);
|
||||
QPixmap pix(JKQTP_PALETTE_ICON_WIDTH,8);
|
||||
QRect r(0,0,JKQTP_PALETTE_ICON_WIDTH-1,7);
|
||||
QPainter p(&pix);
|
||||
p.drawImage(r, img);
|
||||
p.setPen(QPen(QColor("black")));
|
||||
@ -1779,49 +1779,6 @@ QIcon JKQTPMathImageGetPaletteIcon(JKQTPMathImageColorPalette palette) {
|
||||
|
||||
|
||||
|
||||
JKQTPMathImageColorPaletteComboBox::JKQTPMathImageColorPaletteComboBox(QWidget *parent):
|
||||
QComboBox(parent)
|
||||
{
|
||||
setIconSize(QSize(PALETTE_ICON_WIDTH,16));
|
||||
QStringList pal=JKQTPimagePlot_getPredefinedPalettes();
|
||||
clear();
|
||||
for (int i=0; i<pal.size(); i++) {
|
||||
addItem(JKQTPMathImageGetPaletteIcon(i), pal[i]);
|
||||
}
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(intIndexChanged(int)));
|
||||
}
|
||||
|
||||
JKQTPMathImageColorPalette JKQTPMathImageColorPaletteComboBox::colorPalette() const
|
||||
{
|
||||
return JKQTPMathImageColorPalette(currentIndex());
|
||||
}
|
||||
|
||||
JKQTPMathImageColorPalette JKQTPMathImageColorPaletteComboBox::currentColorPalette() const
|
||||
{
|
||||
return colorPalette();
|
||||
|
||||
}
|
||||
|
||||
JKQTPMathImageColorPalette JKQTPMathImageColorPaletteComboBox::getColorPalette() const
|
||||
{
|
||||
return colorPalette();
|
||||
}
|
||||
|
||||
void JKQTPMathImageColorPaletteComboBox::setColorPalette(JKQTPMathImageColorPalette palette)
|
||||
{
|
||||
setCurrentIndex(int(palette));
|
||||
}
|
||||
|
||||
void JKQTPMathImageColorPaletteComboBox::setCurrentColorPalette(JKQTPMathImageColorPalette palette)
|
||||
{
|
||||
setCurrentIndex(int(palette));
|
||||
}
|
||||
|
||||
void JKQTPMathImageColorPaletteComboBox::intIndexChanged(int i)
|
||||
{
|
||||
emit currentPaletteChanged(JKQTPMathImageColorPalette(i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
QImage JKQTPMathImageGetAlphaPaletteImage(int *lut, int lut_size, int width, int height)
|
||||
@ -2097,9 +2054,9 @@ int JKQTPColorPaletteTools::getPalettesCount()
|
||||
}
|
||||
|
||||
QIcon JKQTPColorPaletteTools::getPaletteIcon(int i) {
|
||||
QImage img=getPaletteImage(i, PALETTE_ICON_WIDTH);
|
||||
QPixmap pix(PALETTE_ICON_WIDTH,8);
|
||||
QRect r(0,0,PALETTE_ICON_WIDTH-1,7);
|
||||
QImage img=getPaletteImage(i, JKQTP_PALETTE_ICON_WIDTH);
|
||||
QPixmap pix(JKQTP_PALETTE_ICON_WIDTH,8);
|
||||
QRect r(0,0,JKQTP_PALETTE_ICON_WIDTH-1,7);
|
||||
QPainter p(&pix);
|
||||
p.drawImage(r, img);
|
||||
p.setPen(QPen(QColor("black")));
|
||||
@ -2132,9 +2089,9 @@ QImage JKQTPColorPaletteTools::getPaletteImage(JKQTPMathImageColorPalette palett
|
||||
|
||||
QIcon JKQTPColorPaletteTools::getPaletteKeyIcon(int i)
|
||||
{
|
||||
QImage img=getPaletteKeyImage(i, PALETTE_ICON_WIDTH, PALETTE_IMAGEICON_HEIGHT);
|
||||
QPixmap pix(PALETTE_ICON_WIDTH,PALETTE_IMAGEICON_HEIGHT);
|
||||
QRect r(0,0,PALETTE_ICON_WIDTH-1,PALETTE_IMAGEICON_HEIGHT-1);
|
||||
QImage img=getPaletteKeyImage(i, JKQTP_PALETTE_ICON_WIDTH, JKQTP_PALETTE_IMAGEICON_HEIGHT);
|
||||
QPixmap pix(JKQTP_PALETTE_ICON_WIDTH,JKQTP_PALETTE_IMAGEICON_HEIGHT);
|
||||
QRect r(0,0,JKQTP_PALETTE_ICON_WIDTH-1,JKQTP_PALETTE_IMAGEICON_HEIGHT-1);
|
||||
QPainter p(&pix);
|
||||
p.drawImage(r, img);
|
||||
p.setPen(QPen(QColor("black")));
|
@ -23,7 +23,6 @@
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QComboBox>
|
||||
#include <QStringList>
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include <cmath>
|
||||
@ -40,6 +39,10 @@ class JKQTPhorizontalIndependentAxis; // forward
|
||||
class JKQtBasePlotter; // forward
|
||||
#endif
|
||||
|
||||
#define JKQTP_PALETTE_ICON_WIDTH 64
|
||||
#define JKQTP_PALETTE_IMAGEICON_HEIGHT 64
|
||||
|
||||
|
||||
/*! \brief available palettes for coloring an image
|
||||
\ingroup jkqtplotter_imagelots
|
||||
*/
|
||||
@ -124,26 +127,6 @@ enum JKQTPMathImageColorPalette {
|
||||
|
||||
|
||||
|
||||
/*! \brief class to plot an image from an 2-dimensional array of values
|
||||
\ingroup jkqtplotter_imagelots
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPMathImageColorPaletteComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPMathImageColorPaletteComboBox(QWidget* parent=nullptr);
|
||||
JKQTPMathImageColorPalette colorPalette() const;
|
||||
JKQTPMathImageColorPalette currentColorPalette() const;
|
||||
JKQTPMathImageColorPalette getColorPalette() const;
|
||||
void setColorPalette(JKQTPMathImageColorPalette palette);
|
||||
void setCurrentColorPalette(JKQTPMathImageColorPalette palette);
|
||||
signals:
|
||||
void currentPaletteChanged(JKQTPMathImageColorPalette palette);
|
||||
protected slots:
|
||||
void intIndexChanged(int i);
|
||||
|
||||
};
|
||||
|
||||
/*! \brief modes available for image pixels that are above/below the pixel value range
|
||||
\ingroup jkqtplotter_imagelots
|
||||
*/
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center
|
||||
Copyright (c) 2008-2018 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>)
|
||||
|
||||
|
||||
|
||||
@ -33,18 +33,13 @@
|
||||
#include "jkqtplottertools/jkqtp_imexport.h"
|
||||
#include <QString>
|
||||
#include <QElapsedTimer>
|
||||
#include <QToolBar>
|
||||
#include <QLocale>
|
||||
#include <QPainter>
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
#include <QComboBox>
|
||||
#include <QPrinter>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -53,16 +48,11 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include <cctype>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifndef __WINDOWS__
|
||||
@ -483,20 +473,6 @@ enum JKQTPCAdrawMode {
|
||||
JKQTPCADMnone /*!< \brief draw no axis */
|
||||
};
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPCAdrawMode
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPCAdrawModeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPCAdrawModeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPCAdrawMode getDrawMode() const;
|
||||
void setDrawMode(JKQTPCAdrawMode position);
|
||||
protected:
|
||||
void addDrawMode(JKQTPCAdrawMode position, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
/** \brief converts a JKQTPCAdrawMode variable into a human-readable string
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
@ -540,20 +516,6 @@ LIB_EXPORT QString JKQTPLabelTickMode2String(JKQTPLabelTickMode pos);
|
||||
LIB_EXPORT JKQTPLabelTickMode String2JKQTPLabelTickMode(QString pos);
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPCAlabelType
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPCAlabelTypeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPCAlabelTypeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPCAlabelType getLabelType() const;
|
||||
void setLabelType(JKQTPCAlabelType position);
|
||||
protected:
|
||||
void addLabelType(JKQTPCAlabelType position, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
/** \brief converts a JKQTPCAlabelType variable into a human-readable string
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
@ -574,20 +536,6 @@ enum JKQTPlabelPosition {
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPlabelPosition
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPlabelPositionComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPlabelPositionComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPlabelPosition getPosition() const;
|
||||
void setPosition(JKQTPlabelPosition position);
|
||||
protected:
|
||||
void addPosition(JKQTPlabelPosition position, const QString& name, const QIcon& icon=QIcon());
|
||||
};
|
||||
|
||||
/** \brief converts a JKQTPlabelPosition variable into a human-readable string
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
@ -616,23 +564,6 @@ enum JKQTPkeyPosition {
|
||||
JKQTPkeyInsideBottomRight /*!< \brief the key is positioned inside on the lower bound of the graph */
|
||||
};
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPkeyPosition
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPkeyPositionComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPkeyPositionComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPkeyPosition getPosition() const;
|
||||
void setPosition(JKQTPkeyPosition position);
|
||||
signals:
|
||||
void currentPositionChanged(JKQTPkeyPosition pos);
|
||||
protected:
|
||||
void addPosition(JKQTPkeyPosition position, const QString& name, const QIcon& icon=QIcon());
|
||||
protected slots:
|
||||
void posChanged(int index);
|
||||
};
|
||||
|
||||
/** \brief converts a JKQTPlabelPosition variable into a human-readable string
|
||||
* \ingroup jkqtptools
|
||||
@ -654,24 +585,6 @@ enum JKQTPkeyLayout {
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPkeyPosition
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPkeyLayoutComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPkeyLayoutComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPkeyLayout getKeyLayout() const;
|
||||
void setKeyLayout(JKQTPkeyLayout layout);
|
||||
signals:
|
||||
void currentLayoutChanged(JKQTPkeyLayout layout);
|
||||
protected:
|
||||
void addKeyLayout(JKQTPkeyLayout layout, const QString& name);
|
||||
protected slots:
|
||||
void currentIndexChangedP(int index);
|
||||
};
|
||||
|
||||
/** \brief converts a JKQTPkeyLayout variable into a human-readable string
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
@ -694,28 +607,6 @@ typedef struct {
|
||||
} JKQTPgridPrintingItem;
|
||||
|
||||
|
||||
/** \brief a modified a href="http://doc.trolltech.com/4.5/qtoolbar.html">QToolBar</a> which vanishes when the mouse leaves the toolbar.
|
||||
* \ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKVanishQToolBar: public QToolBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
JKVanishQToolBar(const QString& title, QWidget* parent=nullptr): QToolBar(title, parent) {
|
||||
toolbarVanishes=true;
|
||||
}
|
||||
/** \brief class constructor */
|
||||
JKVanishQToolBar(QWidget* parent=nullptr): QToolBar(parent){
|
||||
toolbarVanishes=true;
|
||||
}
|
||||
JKQTPGET_SET_MACRO(bool, toolbarVanishes)
|
||||
protected:
|
||||
bool toolbarVanishes;
|
||||
/** \brief this event triggers the vanishing of the toolbar */
|
||||
void leaveEvent ( QEvent * /*event*/ ) {
|
||||
if (toolbarVanishes) hide();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@ -758,20 +649,6 @@ enum JKQTPerrorPlotstyle {
|
||||
JKQTPnoError=0 /*!< \brief don't show error information */
|
||||
};
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPerrorPlotstyle
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPerrorPlotstyleComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPerrorPlotstyleComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPerrorPlotstyle getErrorStyle() const;
|
||||
void setSymbol(JKQTPerrorPlotstyle symbol);
|
||||
void setCurrentErrorStyle(JKQTPerrorPlotstyle symbol);
|
||||
protected:
|
||||
void addSymbol(JKQTPerrorPlotstyle symbol, const QString& name, const QIcon &icon=QIcon());
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -845,171 +722,7 @@ LIB_EXPORT QString JKQTPgraphSymbols2NameString(JKQTPgraphSymbols pos);
|
||||
*/
|
||||
LIB_EXPORT JKQTPgraphSymbols String2JKQTPgraphSymbols(QString pos);
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPgraphSymbols
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPSymbolComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPSymbolComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPgraphSymbols getSymbol() const;
|
||||
void setSymbol(JKQTPgraphSymbols symbol);
|
||||
void setCurrentSymbol(JKQTPgraphSymbols symbol);
|
||||
protected:
|
||||
void addSymbol(JKQTPgraphSymbols symbol, const QString& name);
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox to select whether a line, symbols or both should be displayed
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPLinePlotStyleComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPLinePlotStyleComboBox(QWidget* parent=nullptr);
|
||||
|
||||
void setDefaultSymbol(JKQTPgraphSymbols symbol);
|
||||
void addUsedSymbol(JKQTPgraphSymbols symbol);
|
||||
|
||||
JKQTPgraphSymbols getSymbol() const;
|
||||
bool getDrawLine() const;
|
||||
protected:
|
||||
void refill();
|
||||
void addSymbol(JKQTPgraphSymbols symbol, bool line, const QString& name=QString(""), const QVariant& data=QVariant());
|
||||
QList<JKQTPgraphSymbols> symbols;
|
||||
JKQTPgraphSymbols defaultSymbol;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief a QComboBox to select whether a line, symbols or both should be displayed, in addition to JKQTPLinePlotStyleComboBox this may also have different symbol sizes!
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPLinePlotStyleWithSymbolSizeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPLinePlotStyleWithSymbolSizeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
void setDefaultSymbol(JKQTPgraphSymbols symbol, double size);
|
||||
void addUsedSymbol(JKQTPgraphSymbols symbol, double symbolSize, bool line);
|
||||
|
||||
JKQTPgraphSymbols getSymbol() const;
|
||||
bool getDrawLine() const;
|
||||
double getSymbolSize() const;
|
||||
protected:
|
||||
void refill();
|
||||
void addSymbol(JKQTPgraphSymbols symbol, bool line, double symbolSize, const QString& name=QString(""), const QVariant& data=QVariant());
|
||||
struct styleData {
|
||||
JKQTPgraphSymbols symbol;
|
||||
bool line;
|
||||
double symbolSize;
|
||||
bool operator==(const styleData& other)const;
|
||||
};
|
||||
|
||||
QList<styleData> symbols;
|
||||
JKQTPgraphSymbols defaultSymbol;
|
||||
double defaultSize;
|
||||
};
|
||||
|
||||
/*! \brief plot the specified symbol at pixel position x,y
|
||||
\ingroup jkqtptools
|
||||
|
||||
\param painter the QPainter to draw to
|
||||
\param x x-coordinate of the symbol center
|
||||
\param y y-coordinate of the symbol center
|
||||
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
|
||||
\param size size (width/height) of the symbol around (\a x , \a y)
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
*/
|
||||
LIB_EXPORT void JKQTPplotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
|
||||
/*! \brief plot the specified symbol at pixel position x,y
|
||||
\ingroup jkqtptools
|
||||
|
||||
\param paintDevice the paint device to draw on
|
||||
\param x x-coordinate of the symbol center
|
||||
\param y y-coordinate of the symbol center
|
||||
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
|
||||
\param size size (width/height) of the symbol around (\a x , \a y)
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
*/
|
||||
LIB_EXPORT void JKQTPplotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
|
||||
|
||||
/*! \brief plot an arrow between positions (x1,y1) and (x2,y2)
|
||||
\ingroup jkqtptools
|
||||
|
||||
\param painter the QPainter to draw to
|
||||
\param x1 first x-coordinate of the arrow
|
||||
\param y1 first y-coordinate of the arrow
|
||||
\param x2 second x-coordinate of the arrow
|
||||
\param y2 second y-coordinate of the arrow
|
||||
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
|
||||
\param size size (width/height) of the symbol around (\a x , \a y)
|
||||
\param symbolLineWidth width of the lines used to draw the symbol
|
||||
\param color color of the symbol lines
|
||||
\param fillColor color of the symbol filling
|
||||
*/
|
||||
//LIB_EXPORT void JKQTPplotArrow(JKQTPEnhancedPainter& painter, int x, int y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
|
||||
|
||||
|
||||
/*! \brief draw an ellipse without setting pen or brush, or saving the painter!
|
||||
\ingroup jkqtptools
|
||||
|
||||
\return a QVector<QPointF> with points that may be used for drawing
|
||||
\param x center of ellipse (x-coordinate)
|
||||
\param y center of ellipse (y-coordinate)
|
||||
\param a half axis in x-direction
|
||||
\param b half axis in y-direction
|
||||
\param angle_start starting angle of ellipse section
|
||||
\param angle_end ending angle of ellipse section
|
||||
\param alpha rotation angle of ellipse
|
||||
\param controlPoints the number of points to use for drawing
|
||||
\param[out] x_start first point of ellipse
|
||||
\param[out] x_end last point of ellipse
|
||||
|
||||
\note all angles are given in degrees [0..360]
|
||||
*/
|
||||
LIB_EXPORT QVector<QPointF> JKQTPdrawEllipse(double x, double y, double a, double b, double angle_start=0, double angle_end=360, double alpha=0, int controlPoints=180, QPointF* x_start=nullptr, QPointF* x_end=nullptr);
|
||||
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
/*! \brief enhanced QDoubleSpinBox
|
||||
\ingroup jkqtptools
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedDoubleSpinBox : public QDoubleSpinBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPEnhancedDoubleSpinBox(QWidget* parent=nullptr);
|
||||
~JKQTPEnhancedDoubleSpinBox();
|
||||
signals:
|
||||
void editingFinished(double value);
|
||||
protected slots:
|
||||
void intEditingFinished();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#include <QSpinBox>
|
||||
/*! \brief enhanced QDoubleSpinBox
|
||||
\ingroup jkqtptools
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedSpinBox : public QSpinBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPEnhancedSpinBox(QWidget* parent=nullptr);
|
||||
~JKQTPEnhancedSpinBox();
|
||||
signals:
|
||||
void editingFinished(int value);
|
||||
protected slots:
|
||||
void intEditingFinished();
|
||||
};
|
||||
|
||||
inline QString JKQTPCDoubleToQString(double value) {
|
||||
QLocale loc=QLocale::c();
|
||||
@ -1028,163 +741,6 @@ inline QString JKQTPDoubleToQString(double value, int prec = 10, char f = 'g', Q
|
||||
return res;
|
||||
}
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
/*! \brief this class extends the QTableView
|
||||
\ingroup jkqtptools
|
||||
|
||||
This enhanced table view adds some functionality to the Qt class:
|
||||
- return HTML code that describes the table
|
||||
- the selected cells may be copied to Excel using the clipboard (Excel will recognize number !)
|
||||
.
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedTableView : public QTableView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPEnhancedTableView(QWidget* parent=nullptr);
|
||||
virtual ~JKQTPEnhancedTableView();
|
||||
|
||||
/** \brief return the contents of the table view as HTML fragment */
|
||||
QString toHtml(int borderWidth=1, bool non_breaking=false, int fontSizePt=-1) const;
|
||||
void print(QPrinter* printer, bool onePageWide=false, bool onePageHigh=false);
|
||||
|
||||
void paint(QPainter& painter, QRect pageRec=QRect());
|
||||
QSizeF getTotalSize() const;
|
||||
QAction* getPrintAction() const { return printAction; }
|
||||
|
||||
signals:
|
||||
void keyPressed(int key, Qt::KeyboardModifiers modifiers, QString text);
|
||||
public slots:
|
||||
void copySelectionToExcel(int copyrole=Qt::EditRole, bool storeHead=true);
|
||||
void copySelectionToExcelNoHead(int copyrole=Qt::EditRole);
|
||||
void copySelectionToCSV(int copyrole=Qt::EditRole, bool storeHead=true, const QString& separator=", ", const QChar& decimalpoint='.');
|
||||
void copySelectionToCSVNoHead(int copyrole=Qt::EditRole, const QString& separator=", ", const QChar& decimalpoint='.');
|
||||
void print();
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent* event);
|
||||
void paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p=nullptr);
|
||||
|
||||
QPrinter* getPrinter(QPrinter* printerIn=nullptr, bool *localPrinter=nullptr);
|
||||
QAction* printAction;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
/*! \brief this class extends the QPainter
|
||||
\ingroup jkqtptools
|
||||
|
||||
|
||||
*/
|
||||
class LIB_EXPORT JKQTPEnhancedPainter : public QPainter {
|
||||
public:
|
||||
JKQTPEnhancedPainter(QPaintDevice* device);
|
||||
JKQTPEnhancedPainter();
|
||||
virtual ~JKQTPEnhancedPainter();
|
||||
|
||||
|
||||
//void drawPath(const QPainterPath &path);
|
||||
//void drawPoints(const QPoint *points, int pointCount);
|
||||
//void drawPoints(const QPointF *points, int pointCount);
|
||||
// void drawLines(const QLineF *lines, int lineCount);
|
||||
// void drawLines(const QPointF *pointPairs, int lineCount);
|
||||
// void drawLines(const QLine *lines, int lineCount);
|
||||
// void drawLines(const QPoint *pointPairs, int lineCount);
|
||||
|
||||
|
||||
// inline void drawPoint(const QPointF &p) {
|
||||
// drawPoints(&p, 1);
|
||||
// }
|
||||
|
||||
// inline void drawPoint(const QPoint &p) {
|
||||
// drawPoints(&p, 1);
|
||||
// }
|
||||
|
||||
// inline void drawPoint(int x, int y) {
|
||||
// drawPoint(QPointF(x,y));
|
||||
// }
|
||||
|
||||
// inline void drawPoint(double x, double y) {
|
||||
// drawPoint(QPointF(x,y));
|
||||
// }
|
||||
|
||||
// inline void drawPoints(const QPolygonF &points){
|
||||
// drawPoints(points.constData(), points.size());
|
||||
// }
|
||||
|
||||
// inline void drawPoints(const QPolygon &points){
|
||||
// drawPoints(points.constData(), points.size());
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QLineF &line) {
|
||||
// drawLines(&l, 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QLine &line) {
|
||||
// drawLines(&l, 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(int x1, int y1, int x2, int y2) {
|
||||
// drawLines(QLineF(x1,y1,x2,y2), 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(double x1, double y1, double x2, double y2) {
|
||||
// drawLines(QLineF(x1,y1,x2,y2), 1);
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QPoint &p1, const QPoint &p2) {
|
||||
// drawLine(QLineF(QLine(p1, p2)));
|
||||
// }
|
||||
|
||||
// inline void drawLine(const QPointF &p1, const QPointF &p2) {
|
||||
// drawLine(QLineF(p1, p2));
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QLineF> &lines) {
|
||||
// drawLines(lines.constData(), lines.size());
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QPointF> &pointPairs) {
|
||||
// drawLines(pointPairs.constData(), pointPairs.size() / 2);
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QLine> &lines) {
|
||||
// drawLines(lines.constData(), lines.size());
|
||||
// }
|
||||
|
||||
// inline void drawLines(const QVector<QPoint> &pointPairs) {
|
||||
// drawLines(pointPairs.constData(), pointPairs.size() / 2);
|
||||
// }
|
||||
|
||||
// inline void drawRect(const QRectF &rect) {
|
||||
// drawRects(&rect, 1);
|
||||
// }
|
||||
|
||||
// inline void drawRect(int x1, int y1, int w, int h) {
|
||||
// QRectF r(x, y, w, h);
|
||||
// drawRects(&r, 1);
|
||||
// }
|
||||
|
||||
// inline void drawRect(double x1, double y1, double w, double h) {
|
||||
// QRectF r(x, y, w, h);
|
||||
// drawRects(&r, 1);
|
||||
// }
|
||||
|
||||
// inline void drawRect(const QRect &rect) {
|
||||
// drawRects(&r, 1);
|
||||
// }
|
||||
|
||||
protected:
|
||||
virtual void initQEnhacedPainter();
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1360,22 +916,6 @@ enum JKQTPstepType {
|
||||
JKQTPstepRight=2, /*!< \brief datapoint is on the right edge of the hor. step line */
|
||||
};
|
||||
|
||||
/*! \brief a QComboBox which shows JKQTPstepType
|
||||
\ingroup jkqtptools
|
||||
*/
|
||||
class LIB_EXPORT JKQTPstepTypeComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JKQTPstepTypeComboBox(QWidget* parent=nullptr);
|
||||
|
||||
JKQTPstepType getStepType() const;
|
||||
void setStepType(JKQTPstepType step);
|
||||
void setCurrentStepType(JKQTPstepType step);
|
||||
protected:
|
||||
void addStep(JKQTPstepType step, const QString& name, const QIcon &icon=QIcon());
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** \brief converts a JKQTPstepType variable into a human-readable string
|
||||
* \ingroup jkqtptools
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <QDate>
|
||||
#include <QDateTime>
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
|
||||
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -11,12 +11,13 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpcomboboxes.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -3,8 +3,9 @@
|
||||
#include <QDate>
|
||||
#include <QDateTime>
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtpboxplotelements.h"
|
||||
#include "jkqtplotter/jkqtpfilledcurveelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsboxplot.h"
|
||||
#include "jkqtplotter/jkqtpgraphsfilledcurve.h"
|
||||
#include "jkqtplottergui/jkqtpcomboboxes.h"
|
||||
|
||||
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QDate>
|
||||
#include <QDateTime>
|
||||
#include <QApplication>
|
||||
#include "jkqtplottergui/jkqtpcomboboxes.h"
|
||||
|
||||
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -11,13 +11,7 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpgraphspeakstream.h"
|
||||
|
||||
#define N1 200
|
||||
#define N2 50
|
||||
@ -30,7 +24,7 @@ class TestWidgetPeaksPlots : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TestWidgetPeaksPlots(QWidget *parent = 0);
|
||||
explicit TestWidgetPeaksPlots(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpoverlayelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include "jkqtplotter/jkqtpelementsoverlay.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpbaseelements.h"
|
||||
#include "jkqtplotter/jkqtpplotsmodel.h"
|
||||
#include "jkqtplottergui/jkqtpgraphsmodel.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define N1 200
|
||||
|
@ -9,7 +9,7 @@ The soruce code of the main application is (see [`jkqtplotter_simpletest_barchar
|
||||
```c++
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
|
||||
#define Ndata 5
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
|
||||
#define Ndata 5
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
#include "jkqtplotter/jkqtpfilledcurveelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsfilledcurve.h"
|
||||
|
||||
void drawWithDateAxis(JKQtPlotter& plot) {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpfilledcurveelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsfilledcurve.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ The soruce code of the main application is (see [`jkqtplotter_simpletest_imagepl
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
@ -10,7 +10,7 @@ The soruce code of the main application is (see [`jkqtplotter_simpletest_imagepl
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
@ -10,7 +10,7 @@ The soruce code of the main application is (see [`jkqtplotter_simpletest_imagepl
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
@ -13,7 +13,7 @@ The source code of the main application is (see [`jkqtplotter_simpletest_imagepl
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include <opencv/cv.h>
|
||||
|
||||
#ifndef M_PI
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include <opencv/cv.h>
|
||||
|
||||
#ifndef M_PI
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimpulseselements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimpulses.h"
|
||||
|
||||
// number of datapoints:
|
||||
#define Ndata 40
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpgeoelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsgeometric.h"
|
||||
#include "jkqtplottertools/jkqtptools.h"
|
||||
|
||||
#define sqr(x) ((x)*(x))
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -13,7 +13,7 @@ The source code of the main application is (see [`jkqtplotter_simpletest_imagepl
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpimageelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsimage.h"
|
||||
|
||||
|
||||
|
||||
@ -16,15 +16,12 @@ int main(int argc, char* argv[])
|
||||
plot.get_plotter()->set_useAntiAliasingForGraphs(true); // nicer (but slower) plotting
|
||||
plot.get_plotter()->set_useAntiAliasingForSystem(true); // nicer (but slower) plotting
|
||||
plot.get_plotter()->set_useAntiAliasingForText(true); // nicer (but slower) text rendering
|
||||
JKQTPdatastore* ds=plot.getDatastore();
|
||||
|
||||
|
||||
// 2. now we open a BMP-file and load it into an OpenCV cv::Mat
|
||||
QImage image(":/example.bmp");
|
||||
|
||||
|
||||
|
||||
|
||||
// 3. create a graph (JKQTPImage) with a pointer to the QImage-object, generated above
|
||||
JKQTPImage* graph=new JKQTPImage(&plot);
|
||||
graph->set_title("");
|
||||
|
@ -9,7 +9,7 @@ The soruce code of the main application is (see [`jkqtplotter_simpletest_stacked
|
||||
```c++
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
|
||||
#define Ndata 5
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
|
||||
|
||||
template<class TGRAPH>
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <QApplication>
|
||||
#include "jkqtplotter/jkqtplotter.h"
|
||||
#include "jkqtplotter/jkqtpelements.h"
|
||||
#include "jkqtplotter/jkqtpparsedfunctionelements.h"
|
||||
#include "jkqtplotter/jkqtpbarchartelements.h"
|
||||
#include "jkqtplotter/jkqtpgraphs.h"
|
||||
#include "jkqtplotter/jkqtpgraphsparsedfunction.h"
|
||||
#include "jkqtplotter/jkqtpgraphsbarchart.h"
|
||||
#include <random>
|
||||
#include <cmath>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user