using new JKQTPGraphLineAndFillStyleMixin where appropriate

This commit is contained in:
jkriege2 2020-09-19 14:55:46 +02:00
parent 6875e0ae6c
commit 34fa59ebf4
7 changed files with 315 additions and 341 deletions

View File

@ -33,13 +33,12 @@
JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase(JKQTBasePlotter* parent): JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase(JKQTBasePlotter* parent):
JKQTPEvaluatedFunctionWithErrorsGraphBase(parent), JKQTPEvaluatedFunctionWithErrorsGraphBase(parent),
drawLine(true),
fillCurve(false),
drawErrorPolygons(false), drawErrorPolygons(false),
drawErrorLines(false) drawErrorLines(false)
{ {
initLineStyle(parent, parentPlotStyle); initLineStyle(parent, parentPlotStyle);
initFillStyle(parent, parentPlotStyle); initFillStyle(parent, parentPlotStyle);
setFillCurve(false);
errorColor=getLineColor().lighter(); errorColor=getLineColor().lighter();
errorFillColor=getLineColor().lighter(); errorFillColor=getLineColor().lighter();
@ -71,16 +70,6 @@ JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::~JKQTPEvaluatedFunctionWithErr
} }
void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::setDrawLine(bool __value)
{
this->drawLine = __value;
}
bool JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::getDrawLine() const
{
return this->drawLine;
}
void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) { void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QPen p=getLinePen(painter, parent); QPen p=getLinePen(painter, parent);
@ -90,10 +79,10 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawKeyMarker(JKQTPEnhanc
QBrush b=getFillBrush(painter, parent); QBrush b=getFillBrush(painter, parent);
const double y=rect.top()+rect.height()/2.0; const double y=rect.top()+rect.height()/2.0;
painter.setPen(np); painter.setPen(np);
if (drawLine) painter.setPen(p); if (getDrawLine()) painter.setPen(p);
painter.setBrush(b); painter.setBrush(b);
if (fillCurve) painter.drawRect(rect); if (getFillCurve()) painter.drawRect(rect);
if (!fillCurve && drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); if (!getFillCurve() && getDrawLine()) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
} }
@ -262,7 +251,7 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawXGraph(JKQTPEnhancedP
y=qBound(yami, y, yama); y=qBound(yami, y, yama);
if (fillCurve) { if (getFillCurve()) {
if (!first) filledPolygon<<QPointF(x, y0); if (!first) filledPolygon<<QPointF(x, y0);
filledPolygon<<QPointF(x, y); filledPolygon<<QPointF(x, y);
if (it+1==data.end()) filledPolygon<<QPointF(x, y0); if (it+1==data.end()) filledPolygon<<QPointF(x, y0);
@ -273,7 +262,7 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawXGraph(JKQTPEnhancedP
epBottom<<QPointF(x, yme); epBottom<<QPointF(x, yme);
} }
if (drawLine) { if (getDrawLine()) {
linePolygon<<QPointF(x, y); linePolygon<<QPointF(x, y);
} }
@ -299,13 +288,13 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawXGraph(JKQTPEnhancedP
painter.drawPolygon(poly, Qt::OddEvenFill); painter.drawPolygon(poly, Qt::OddEvenFill);
} }
if (fillCurve) { if (getFillCurve()) {
painter.save(); auto __finalpaintfillc=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaintfillc=JKQTPFinally([&painter]() {painter.restore();});
painter.setBrush(b); painter.setBrush(b);
painter.setPen(np); painter.setPen(np);
painter.drawPolygon(filledPolygon, Qt::OddEvenFill); painter.drawPolygon(filledPolygon, Qt::OddEvenFill);
} }
if (drawLine) { if (getDrawLine()) {
painter.save(); auto __finalpaintline=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaintline=JKQTPFinally([&painter]() {painter.restore();});
painter.setPen(p); painter.setPen(p);
painter.drawPolyline(linePolygon); painter.drawPolyline(linePolygon);
@ -389,7 +378,7 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawYGraph(JKQTPEnhancedP
x=qBound(xami, x, xama); x=qBound(xami, x, xama);
if (fillCurve) { if (getFillCurve()) {
if (!first) filledPolygon<<QPointF(x0, y); if (!first) filledPolygon<<QPointF(x0, y);
filledPolygon<<QPointF(x, y); filledPolygon<<QPointF(x, y);
if (it+1==data.end()) filledPolygon<<QPointF(x0, y); if (it+1==data.end()) filledPolygon<<QPointF(x0, y);
@ -400,7 +389,7 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawYGraph(JKQTPEnhancedP
epBottom<<QPointF(xme, y); epBottom<<QPointF(xme, y);
} }
if (drawLine) { if (getDrawLine()) {
linePolygon<<QPointF(x, y); linePolygon<<QPointF(x, y);
} }
@ -425,13 +414,13 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawYGraph(JKQTPEnhancedP
} }
painter.drawPolygon(poly, Qt::OddEvenFill); painter.drawPolygon(poly, Qt::OddEvenFill);
} }
if (fillCurve) { if (getFillCurve()) {
painter.save(); auto __finalpaintfillc=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaintfillc=JKQTPFinally([&painter]() {painter.restore();});
painter.setBrush(b); painter.setBrush(b);
painter.setPen(np); painter.setPen(np);
painter.drawPolygon(filledPolygon, Qt::OddEvenFill); painter.drawPolygon(filledPolygon, Qt::OddEvenFill);
} }
if (drawLine) { if (getDrawLine()) {
painter.save(); auto __finalpaintline=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaintline=JKQTPFinally([&painter]() {painter.restore();});
painter.setPen(p); painter.setPen(p);
painter.drawPolyline(linePolygon); painter.drawPolyline(linePolygon);

View File

@ -44,7 +44,7 @@
* *
* \see e.g. JKQTPXFunctionLineGraph for a concrete implementation * \see e.g. JKQTPXFunctionLineGraph for a concrete implementation
*/ */
class JKQTPLOTTER_LIB_EXPORT JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase: public JKQTPEvaluatedFunctionWithErrorsGraphBase, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin { class JKQTPLOTTER_LIB_EXPORT JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase: public JKQTPEvaluatedFunctionWithErrorsGraphBase, public JKQTPGraphLineAndFillStyleMixin {
Q_OBJECT Q_OBJECT
public: public:
@ -62,8 +62,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase: p
/** \brief returns the color to be used for the key label */ /** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor() const override; virtual QColor getKeyLabelColor() const override;
/*! \copydoc drawLine */
bool getDrawLine() const;
/*! \copydoc drawErrorPolygons */ /*! \copydoc drawErrorPolygons */
@ -89,8 +87,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase: p
/*! \brief set color, fill color and error color at the same time */ /*! \brief set color, fill color and error color at the same time */
void setColor(QColor c); void setColor(QColor c);
/*! \copydoc drawLine */
void setDrawLine(bool __value);
/*! \copydoc drawErrorPolygons */ /*! \copydoc drawErrorPolygons */
void setDrawErrorPolygons(bool __value); void setDrawErrorPolygons(bool __value);
/*! \copydoc drawErrorLines */ /*! \copydoc drawErrorLines */
@ -115,12 +112,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase: p
/** \brief indicates whether to draw a line or not */
bool drawLine;
/** \brief indicates whether to fill the space between the curve and the x-axis */
bool fillCurve;
/** \brief indicates whether an error polygon should be drawn */ /** \brief indicates whether an error polygon should be drawn */
bool drawErrorPolygons; bool drawErrorPolygons;
/** \brief indicates whether error lines should be drawn */ /** \brief indicates whether error lines should be drawn */

View File

@ -187,9 +187,12 @@ void JKQTPFilledVerticalRangeGraph::draw(JKQTPEnhancedPainter &painter)
poly_all.append(plow[i]); poly_all.append(plow[i]);
} }
} }
if (getFillCurve()) {
painter.setBrush(b); painter.setBrush(b);
painter.setPen(np); painter.setPen(np);
painter.drawPolygon(poly_all); painter.drawPolygon(poly_all);
}
if (getDrawLine()) { if (getDrawLine()) {
@ -299,9 +302,12 @@ void JKQTPFilledHorizontalRangeGraph::draw(JKQTPEnhancedPainter &painter)
poly_all.append(plow[i]); poly_all.append(plow[i]);
} }
} }
if (getFillCurve()) {
painter.setBrush(b); painter.setBrush(b);
painter.setPen(np); painter.setPen(np);
painter.drawPolygon(poly_all); painter.drawPolygon(poly_all);
}
if (getDrawLine()) { if (getDrawLine()) {

View File

@ -39,8 +39,6 @@
JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter* parent): JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter* parent):
JKQTPXYGraph(parent) JKQTPXYGraph(parent)
{ {
m_drawLine=true;
m_fillCurve=false;
m_drawSymbols=false; m_drawSymbols=false;
m_specialLineType=JKQTPStepLeft; m_specialLineType=JKQTPStepLeft;
m_baseline=0; m_baseline=0;
@ -49,6 +47,7 @@ JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter
initLineStyle(parent, parentPlotStyle); initLineStyle(parent, parentPlotStyle);
initFillStyle(parent, parentPlotStyle); initFillStyle(parent, parentPlotStyle);
initSymbolStyle(parent, parentPlotStyle); initSymbolStyle(parent, parentPlotStyle);
setFillCurve(false);
} }
@ -65,10 +64,10 @@ void JKQTPSpecialLineHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painte
QBrush b=getFillBrush(painter, parent); QBrush b=getFillBrush(painter, parent);
const double y=rect.top()+rect.height()/2.0; const double y=rect.top()+rect.height()/2.0;
painter.setPen(np); painter.setPen(np);
if (m_drawLine) painter.setPen(p); if (getDrawLine()) painter.setPen(p);
painter.setBrush(b); painter.setBrush(b);
if (m_fillCurve) painter.drawRect(rect); if (getFillCurve()) painter.drawRect(rect);
if (!m_fillCurve && m_drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y)); if (!getFillCurve() && getDrawLine()) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
if (m_drawSymbols) { if (m_drawSymbols) {
plotStyledSymbol(parent, painter, rect.center().x(), rect.center().y(), rect.width()*0.5); plotStyledSymbol(parent, painter, rect.center().x(), rect.center().y(), rect.width()*0.5);
} }
@ -79,16 +78,6 @@ QColor JKQTPSpecialLineHorizontalGraph::getKeyLabelColor() const {
return getLineColor(); return getLineColor();
} }
void JKQTPSpecialLineHorizontalGraph::setDrawLine(bool __value)
{
this->m_drawLine = __value;
}
bool JKQTPSpecialLineHorizontalGraph::getDrawLine() const
{
return this->m_drawLine;
}
void JKQTPSpecialLineHorizontalGraph::setDrawSymbols(bool __value) void JKQTPSpecialLineHorizontalGraph::setDrawSymbols(bool __value)
{ {
m_drawSymbols=__value; m_drawSymbols=__value;
@ -99,15 +88,6 @@ bool JKQTPSpecialLineHorizontalGraph::getDrawSymbols() const
return m_drawSymbols; return m_drawSymbols;
} }
void JKQTPSpecialLineHorizontalGraph::setFillCurve(bool __value)
{
this->m_fillCurve = __value;
}
bool JKQTPSpecialLineHorizontalGraph::getFillCurve() const
{
return this->m_fillCurve;
}
void JKQTPSpecialLineHorizontalGraph::setSpecialLineType(const JKQTPSpecialLineType &__value) void JKQTPSpecialLineHorizontalGraph::setSpecialLineType(const JKQTPSpecialLineType &__value)
{ {
@ -155,16 +135,11 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
QPen np(Qt::NoPen); QPen np(Qt::NoPen);
QBrush b=getFillBrush(painter, parent); QBrush b=getFillBrush(painter, parent);
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); int imax=0;
int imin=0; int imin=0;
if (imax<imin) { if (getIndexRange(imin, imax)) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
QPainterPath pl, pf; QPainterPath pl, pf;
QVector<QPointF> ps; QVector<QPointF> ps;
@ -184,13 +159,13 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
bool subsequentItem=false; bool subsequentItem=false;
intSortData(); intSortData();
for (int iii=imin; iii<imax; iii++) { for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax); const int i=qBound(imin, getDataIndex(iii), imax);
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i)); const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i)); const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
//std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n"; //std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n";
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
double x=transformX(xv); const double x=transformX(xv);
double y=transformY(yv); const double y=transformY(yv);
if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) { if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) {
ps.append(QPointF(x,y)); ps.append(QPointF(x,y));
if (subsequentItem) { if (subsequentItem) {
@ -209,7 +184,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
pf.lineTo(xold+d/2.0, yold); pf.lineTo(xold+d/2.0, yold);
pf.lineTo(xold+d/2.0, y); pf.lineTo(xold+d/2.0, y);
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(xold+d/2.0, yold); pl.lineTo(xold+d/2.0, yold);
pl.lineTo(xold+d/2.0, y); pl.lineTo(xold+d/2.0, y);
pl.lineTo(x, y); pl.lineTo(x, y);
@ -222,7 +197,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
// xold/yold // xold/yold
pf.lineTo(xold, y); pf.lineTo(xold, y);
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(xold, y); pl.lineTo(xold, y);
pl.lineTo(x, y); pl.lineTo(x, y);
} }
@ -234,7 +209,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
// xold/yold // xold/yold
pf.lineTo(x, yold); pf.lineTo(x, yold);
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(x, yold); pl.lineTo(x, yold);
pl.lineTo(x, y); pl.lineTo(x, y);
} }
@ -251,7 +226,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
pf.lineTo(xold, yold+h/2.0); pf.lineTo(xold, yold+h/2.0);
pf.lineTo(x, yold+h/2.0); pf.lineTo(x, yold+h/2.0);
pf.lineTo(x,y); pf.lineTo(x,y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(xold, yold+h/2.0); pl.lineTo(xold, yold+h/2.0);
pl.lineTo(x, yold+h/2.0); pl.lineTo(x, yold+h/2.0);
pl.lineTo(x,y); pl.lineTo(x,y);
@ -263,14 +238,14 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
// *----/ // *----/
// xold/yold // xold/yold
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(x, y); pl.lineTo(x, y);
} }
} }
//std::cout<<"line ("<<xl1<<", "<<yl1<<") -- ("<<xl2<<", "<<yl2<<")"<<std::endl; //std::cout<<"line ("<<xl1<<", "<<yl1<<") -- ("<<xl2<<", "<<yl2<<")"<<std::endl;
} else { } else {
if (m_drawLine) pl.moveTo(x,y); if (getDrawLine()) pl.moveTo(x,y);
pf.moveTo(x, y0); pf.moveTo(x, y0);
pf.lineTo(x, y); pf.lineTo(x, y);
//xstart=x; //xstart=x;
@ -282,14 +257,14 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
} }
} }
} }
if (m_fillCurve) { if (getFillCurve()) {
pf.lineTo(xold, y0); pf.lineTo(xold, y0);
pf.closeSubpath(); pf.closeSubpath();
} }
painter.save(); painter.save();
auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
if (m_fillCurve) { if (getFillCurve()) {
painter.fillPath(pf, b); painter.fillPath(pf, b);
} }
@ -299,7 +274,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
painter.drawPath(pl); painter.drawPath(pl);
} }
if (m_drawLine) { if (getDrawLine()) {
painter.setBrush(QBrush(Qt::transparent)); painter.setBrush(QBrush(Qt::transparent));
painter.setPen(p); painter.setPen(p);
painter.drawPath(pl); painter.drawPath(pl);
@ -312,7 +287,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
plotStyledSymbol(parent, painter, ppoint.x(), ppoint.y()); plotStyledSymbol(parent, painter, ppoint.x(), ppoint.y());
} }
} }
}
drawErrorsAfter(painter); drawErrorsAfter(painter);
} }
@ -353,16 +328,11 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
QPen np(Qt::NoPen); QPen np(Qt::NoPen);
QBrush b=getFillBrush(painter, parent); QBrush b=getFillBrush(painter, parent);
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); int imax=0;
int imin=0; int imin=0;
if (imax<imin) { if (getIndexRange(imin, imax)) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
QPainterPath pl, pf; QPainterPath pl, pf;
QVector<QPointF> ps; QVector<QPointF> ps;
@ -377,13 +347,13 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
bool first=false; bool first=false;
intSortData(); intSortData();
for (int iii=imin; iii<imax; iii++) { for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax); const int i=qBound(imin, getDataIndex(iii), imax);
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i)); const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i)); const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
//std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n"; //std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n";
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
double x=transformX(xv); const double x=transformX(xv);
double y=transformY(yv); const double y=transformY(yv);
if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) { if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) {
ps.append(QPointF(x,y)); ps.append(QPointF(x,y));
if (first) { if (first) {
@ -397,7 +367,7 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
pf.lineTo(xold, yold+d/2.0); pf.lineTo(xold, yold+d/2.0);
pf.lineTo(x, yold+d/2.0); pf.lineTo(x, yold+d/2.0);
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(xold, yold+d/2.0); pl.lineTo(xold, yold+d/2.0);
pl.lineTo(x, yold+d/2.0); pl.lineTo(x, yold+d/2.0);
pl.lineTo(x, y); pl.lineTo(x, y);
@ -405,14 +375,14 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
} else if (m_specialLineType==JKQTPStepLeft) { } else if (m_specialLineType==JKQTPStepLeft) {
pf.lineTo(x, yold); pf.lineTo(x, yold);
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(x, yold); pl.lineTo(x, yold);
pl.lineTo(x, y); pl.lineTo(x, y);
} }
} else if (m_specialLineType==JKQTPStepRight) { } else if (m_specialLineType==JKQTPStepRight) {
pf.lineTo(xold, y); pf.lineTo(xold, y);
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(xold, y); pl.lineTo(xold, y);
pl.lineTo(x, y); pl.lineTo(x, y);
} }
@ -429,7 +399,7 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
pf.lineTo(xold+d/2.0, yold); pf.lineTo(xold+d/2.0, yold);
pf.lineTo(xold+d/2.0, y); pf.lineTo(xold+d/2.0, y);
pf.lineTo(x,y); pf.lineTo(x,y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(xold+d/2.0, yold); pl.lineTo(xold+d/2.0, yold);
pl.lineTo(xold+d/2.0, y); pl.lineTo(xold+d/2.0, y);
pl.lineTo(x,y); pl.lineTo(x,y);
@ -441,14 +411,14 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
// *----/ // *----/
// xold/yold // xold/yold
pf.lineTo(x, y); pf.lineTo(x, y);
if (m_drawLine) { if (getDrawLine()) {
pl.lineTo(x, y); pl.lineTo(x, y);
} }
} }
//std::cout<<"line ("<<xl1<<", "<<yl1<<") -- ("<<xl2<<", "<<yl2<<")"<<std::endl; //std::cout<<"line ("<<xl1<<", "<<yl1<<") -- ("<<xl2<<", "<<yl2<<")"<<std::endl;
} else { } else {
if (m_drawLine) pl.moveTo(x,y); if (getDrawLine()) pl.moveTo(x,y);
pf.moveTo(x0, y); pf.moveTo(x0, y);
pf.lineTo(x, y); pf.lineTo(x, y);
} }
@ -462,7 +432,7 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
pf.closeSubpath(); pf.closeSubpath();
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
if (m_fillCurve) { if (getFillCurve()) {
painter.fillPath(pf, b); painter.fillPath(pf, b);
} }
@ -472,7 +442,7 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
painter.drawPath(pl); painter.drawPath(pl);
} }
if (m_drawLine) { if (getDrawLine()) {
painter.setBrush(QBrush(Qt::transparent)); painter.setBrush(QBrush(Qt::transparent));
painter.setPen(p); painter.setPen(p);
painter.drawPath(pl); painter.drawPath(pl);
@ -485,6 +455,7 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
plotStyledSymbol(parent, painter, point.x(), point.y()); plotStyledSymbol(parent, painter, point.x(), point.y());
} }
} }
}
drawErrorsAfter(painter); drawErrorsAfter(painter);
} }

View File

@ -50,7 +50,7 @@ class JKQTPDatastore;
\see JKQTPSpecialLineVerticalGraph, JKQTPFilledCurveXGraph, \ref JKQTPlotterSpecialStepLinePlot \see JKQTPSpecialLineVerticalGraph, JKQTPFilledCurveXGraph, \ref JKQTPlotterSpecialStepLinePlot
*/ */
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin, public JKQTPGraphSymbolStyleMixin { class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYGraph, public JKQTPGraphLineAndFillStyleMixin, public JKQTPGraphSymbolStyleMixin {
Q_OBJECT Q_OBJECT
public: public:
/** \brief class constructor */ /** \brief class constructor */
@ -65,18 +65,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYGrap
/** \brief returns the color to be used for the key label */ /** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor() const override; virtual QColor getKeyLabelColor() const override;
/*! sets whether to draw a line or not */
void setDrawLine(bool __value);
/*! returns whether the graph line is drawn */
bool getDrawLine() const;
/*! sets whether to draw symbols */ /*! sets whether to draw symbols */
void setDrawSymbols(bool __value); void setDrawSymbols(bool __value);
/*! returns whether symbols are drawn */ /*! returns whether symbols are drawn */
bool getDrawSymbols() const; bool getDrawSymbols() const;
/*! sets whether to fill the space between the curve and the baseline/x-axis */
void setFillCurve(bool __value);
/*! returns whether the space between the curve and the baseline/x-axis is filled */
bool getFillCurve() const;
/** \brief set the type of connecting (step-)lines */ /** \brief set the type of connecting (step-)lines */
void setSpecialLineType(const JKQTPSpecialLineType & __value); void setSpecialLineType(const JKQTPSpecialLineType & __value);
/** \brief get the type of connecting (step-)lines */ /** \brief get the type of connecting (step-)lines */
@ -88,12 +81,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYGrap
/** \brief set line-color, fill color and symbol color */ /** \brief set line-color, fill color and symbol color */
void setColor(QColor c); void setColor(QColor c);
protected: protected:
/** \brief indicates whether to draw a line or not */
bool m_drawLine;
/** \brief indicates whether to draw a symbols or not */ /** \brief indicates whether to draw a symbols or not */
bool m_drawSymbols; bool m_drawSymbols;
/** \brief indicates whether to fill the space between the curve and the baseline/x-axis */
bool m_fillCurve;
/** \brief type of connecting (step)lines */ /** \brief type of connecting (step)lines */
JKQTPSpecialLineType m_specialLineType; JKQTPSpecialLineType m_specialLineType;
/** \brief baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!) */ /** \brief baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!) */

View File

@ -567,7 +567,7 @@ double JKQTPGraphDecoratedHeadLineStyleMixin::calcHeadDecoratorSize(double line_
JKQTPGraphLineAndFillStyleMixin::JKQTPGraphLineAndFillStyleMixin(): JKQTPGraphLineAndFillStyleMixin::JKQTPGraphLineAndFillStyleMixin():
m_drawLine(true) m_drawLine(true), m_fillCurve(true)
{ {
} }
@ -586,3 +586,18 @@ bool JKQTPGraphLineAndFillStyleMixin::doDrawLine() const
{ {
return m_drawLine; return m_drawLine;
} }
void JKQTPGraphLineAndFillStyleMixin::setFillCurve(bool __value)
{
m_fillCurve=__value;
}
bool JKQTPGraphLineAndFillStyleMixin::getFillCurve() const
{
return m_fillCurve;
}
bool JKQTPGraphLineAndFillStyleMixin::doFillCurve() const
{
return m_fillCurve;
}

View File

@ -461,10 +461,22 @@ public:
bool getDrawLine() const; bool getDrawLine() const;
/*! \copydoc m_drawLine */ /*! \copydoc m_drawLine */
bool doDrawLine() const; bool doDrawLine() const;
/*! \copydoc m_fillCurve */
void setFillCurve(bool __value);
/*! \copydoc m_fillCurve */
bool getFillCurve() const;
/*! \copydoc m_fillCurve */
bool doFillCurve() const;
Q_PROPERTY(bool drawLine MEMBER m_drawLine READ getDrawLine WRITE setDrawLine) Q_PROPERTY(bool drawLine MEMBER m_drawLine READ getDrawLine WRITE setDrawLine)
Q_PROPERTY(bool fillCurve MEMBER m_fillCurve READ getFillCurve WRITE setFillCurve)
private: private:
/** \brief indicates whether to draw a line on the circumference of the described area (i.e. along the data points from \c xColumn and \c yColumn as well as \c xColumn and \c yColumn2 or not */ /** \brief indicates whether to draw a line on the circumference of the described area (i.e. along the data points from \c xColumn and \c yColumn as well as \c xColumn and \c yColumn2 or not */
bool m_drawLine; bool m_drawLine;
/** \brief indicates whether to fill the space between the curve and the x-axis */
bool m_fillCurve;
}; };