mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-15 18:15:52 +08:00
moved set/getBaseline() to a special base graph class JKQTPXYBaselineGraph
This commit is contained in:
parent
34fa59ebf4
commit
d57da36a99
@ -92,7 +92,7 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
int lr=datastore->getNextHigherIndex(xColumn, i);
|
||||
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
|
||||
double yv0=y0;
|
||||
if (!qFuzzyIsNull(baseline)) yv0=transformY(baseline);
|
||||
if (!qFuzzyIsNull(getBaseline())) yv0=transformY(getBaseline());
|
||||
if (hasStackPar) {
|
||||
double stackLastY=getParentStackedMax(i);
|
||||
const double yvold=yv;
|
||||
@ -276,7 +276,7 @@ void JKQTPBarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
int sr=datastore->getNextLowerIndex(yColumn, i);
|
||||
int lr=datastore->getNextHigherIndex(yColumn, i);
|
||||
double xv0=x0;
|
||||
if (!qFuzzyIsNull(baseline)) xv0=transformX(baseline);
|
||||
if (!qFuzzyIsNull(getBaseline())) xv0=transformX(getBaseline());
|
||||
if (hasStackPar) {
|
||||
double stackLastX=getParentStackedMax(i);
|
||||
const double xvold=xv;
|
||||
@ -300,7 +300,7 @@ void JKQTPBarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
|
||||
double x=xv0;
|
||||
if (!qFuzzyIsNull(baseline)) x=transformX(baseline);
|
||||
if (!qFuzzyIsNull(getBaseline())) x=transformX(getBaseline());
|
||||
double y=transformY(yv+shift*delta+width*deltap);
|
||||
double xx=transformX(xv);
|
||||
double yy=transformY(yv+shift*delta-width*deltam);
|
||||
@ -456,10 +456,10 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
|
||||
miny=0;
|
||||
maxy=0;
|
||||
smallestGreaterZero=0;
|
||||
if (baseline>0) {
|
||||
smallestGreaterZero=baseline;
|
||||
miny=baseline;
|
||||
maxy=baseline;
|
||||
if (getBaseline()>0) {
|
||||
smallestGreaterZero=getBaseline();
|
||||
miny=getBaseline();
|
||||
maxy=getBaseline();
|
||||
}
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
@ -476,7 +476,7 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
|
||||
if (imax<0) imax=0;
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double yv=baseline;
|
||||
double yv=getBaseline();
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
if (yv>maxy) maxy=yv;
|
||||
if (yv<miny) miny=yv;
|
||||
@ -494,13 +494,13 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
|
||||
return true;
|
||||
} else {
|
||||
bool start=false;
|
||||
miny=baseline;
|
||||
maxy=baseline;
|
||||
miny=getBaseline();
|
||||
maxy=getBaseline();
|
||||
smallestGreaterZero=0;
|
||||
if (baseline>0) {
|
||||
smallestGreaterZero=baseline;
|
||||
miny=baseline;
|
||||
maxy=baseline;
|
||||
if (getBaseline()>0) {
|
||||
smallestGreaterZero=getBaseline();
|
||||
miny=getBaseline();
|
||||
maxy=getBaseline();
|
||||
}
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
@ -610,7 +610,7 @@ double JKQTPBarVerticalStackableGraph::getParentStackedMax(int index) const
|
||||
if (stackParent) {
|
||||
return stackParent->getStackedMax(index);
|
||||
} else {
|
||||
return baseline;
|
||||
return getBaseline();
|
||||
}
|
||||
}
|
||||
|
||||
@ -695,7 +695,7 @@ double JKQTPBarHorizontalStackableGraph::getParentStackedMax(int index) const
|
||||
if (stackParent) {
|
||||
return stackParent->getStackedMax(index);
|
||||
} else {
|
||||
return baseline;
|
||||
return getBaseline();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
JKQTPBarGraphBase::JKQTPBarGraphBase(JKQTBasePlotter* parent):
|
||||
JKQTPXYGraph(parent), width(0.9), shift(0), baseline(0.0)
|
||||
JKQTPXYBaselineGraph(parent), width(0.9), shift(0)
|
||||
{
|
||||
initFillStyle(parent, parentPlotStyle);
|
||||
initLineStyle(parent, parentPlotStyle);
|
||||
@ -134,16 +134,6 @@ double JKQTPBarGraphBase::getWidth() const
|
||||
return this->width;
|
||||
}
|
||||
|
||||
void JKQTPBarGraphBase::setBaseline(double __value)
|
||||
{
|
||||
this->baseline = __value;
|
||||
}
|
||||
|
||||
double JKQTPBarGraphBase::getBaseline() const
|
||||
{
|
||||
return this->baseline;
|
||||
}
|
||||
|
||||
void JKQTPBarGraphBase::setFillColor_and_darkenedColor(QColor fill, int colorDarker)
|
||||
{
|
||||
setFillColor(fill);
|
||||
@ -152,7 +142,7 @@ void JKQTPBarGraphBase::setFillColor_and_darkenedColor(QColor fill, int colorDar
|
||||
|
||||
double JKQTPBarGraphBase::getParentStackedMax(int /*index*/) const
|
||||
{
|
||||
return baseline;
|
||||
return getBaseline();
|
||||
}
|
||||
|
||||
bool JKQTPBarGraphBase::hasStackParent() const
|
||||
@ -165,10 +155,10 @@ bool JKQTPBarGraphBase::getValuesMinMax(double &mmin, double &mmax, double &smal
|
||||
mmin=0;
|
||||
mmax=0;
|
||||
smallestGreaterZero=0;
|
||||
if (baseline>0) {
|
||||
smallestGreaterZero=baseline;
|
||||
mmin=baseline;
|
||||
mmax=baseline;
|
||||
if (getBaseline()>0) {
|
||||
smallestGreaterZero=getBaseline();
|
||||
mmin=getBaseline();
|
||||
mmax=getBaseline();
|
||||
}
|
||||
|
||||
if (getBarPositionColumn()<0 || getBarHeightColumn()<0) return false;
|
||||
@ -184,7 +174,7 @@ bool JKQTPBarGraphBase::getValuesMinMax(double &mmin, double &mmax, double &smal
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double stack=0;
|
||||
double yv=baseline;
|
||||
double yv=getBaseline();
|
||||
const double boxstart=getParentStackedMax(i);
|
||||
if (hasStackParent()) {
|
||||
stack=boxstart;
|
||||
|
@ -54,7 +54,7 @@
|
||||
*
|
||||
* \see JKQTPBarHorizontalGraph, JKQTPBarVerticalGraph
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPBarGraphBase: public JKQTPXYGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin {
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPBarGraphBase: public JKQTPXYBaselineGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
@ -73,8 +73,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPBarGraphBase: public JKQTPXYGraph, public JKQT
|
||||
double getShift() const;
|
||||
/*! \copydoc width */
|
||||
double getWidth() const;
|
||||
/*! \copydoc baseline */
|
||||
double getBaseline() const;
|
||||
|
||||
/** \brief sets the fill color and the color together, where fillColor is set to \a fill and the line-color is set to \c fill.darker(colorDarker)
|
||||
* \see setColor()
|
||||
*/
|
||||
@ -103,8 +102,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPBarGraphBase: public JKQTPXYGraph, public JKQT
|
||||
void setShift(double __value);
|
||||
/*! \copydoc width */
|
||||
void setWidth(double __value);
|
||||
/*! \copydoc baseline */
|
||||
void setBaseline(double __value);
|
||||
|
||||
|
||||
/** \brief set outline and fill color at the same time
|
||||
* \see setFillColor_and_darkenedColor()
|
||||
@ -137,9 +135,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPBarGraphBase: public JKQTPXYGraph, public JKQT
|
||||
*/
|
||||
double shift;
|
||||
|
||||
/** \brief baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!)
|
||||
*/
|
||||
double baseline;
|
||||
|
||||
/** \brief this function is used by autoscaleBarWidthAndShift() to determine whether a given graph shall be taken into account when autoscaling.
|
||||
* Typically this returns \c true for all JKQTPBarGraphBase-derved objects with the same orientation (horizontal or vertical) */
|
||||
|
@ -35,9 +35,8 @@
|
||||
|
||||
|
||||
JKQTPImpulsesHorizontalGraph::JKQTPImpulsesHorizontalGraph(JKQTBasePlotter* parent):
|
||||
JKQTPXYGraph(parent)
|
||||
JKQTPXYBaselineGraph(parent)
|
||||
{
|
||||
baseline=0;
|
||||
drawSymbols=false;
|
||||
initLineStyle(parent, parentPlotStyle);
|
||||
initSymbolStyle(parent, parentPlotStyle);
|
||||
@ -76,15 +75,15 @@ void JKQTPImpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
//double xold=-1;
|
||||
//double yold=-1;
|
||||
double x0=transformX(baseline);
|
||||
double x0=transformX(getBaseline());
|
||||
if (parent->getXAxis()->isLogAxis()) {
|
||||
if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline);
|
||||
if (getBaseline()>0 && getBaseline()>parent->getXAxis()->getMin()) x0=transformX(getBaseline());
|
||||
else x0=transformX(parent->getXAxis()->getMin());
|
||||
}
|
||||
// double y0=transformY(baseline);
|
||||
// double y0=transformY(getBaseline());
|
||||
// if (parent->getYAxis()->isLogAxis()) {
|
||||
// y0=transformY(parent->getYAxis()->getMin());
|
||||
// if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline);
|
||||
// if (getBaseline()>0 && getBaseline()>parent->getYAxis()->getMin()) y0=transformY(getBaseline());
|
||||
// else y0=transformY(parent->getYAxis()->getMin());
|
||||
// }
|
||||
//bool first=false;
|
||||
@ -145,16 +144,6 @@ void JKQTPImpulsesHorizontalGraph::setColor(QColor c)
|
||||
setHighlightingLineColor(c);
|
||||
}
|
||||
|
||||
void JKQTPImpulsesHorizontalGraph::setBaseline(double __value)
|
||||
{
|
||||
this->baseline = __value;
|
||||
}
|
||||
|
||||
double JKQTPImpulsesHorizontalGraph::getBaseline() const
|
||||
{
|
||||
return this->baseline;
|
||||
}
|
||||
|
||||
void JKQTPImpulsesHorizontalGraph::setDrawSymbols(bool __value)
|
||||
{
|
||||
drawSymbols=__value;
|
||||
@ -214,15 +203,15 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
//double xold=-1;
|
||||
//double yold=-1;
|
||||
//bool first=false;
|
||||
// double x0=transformX(baseline);
|
||||
// double x0=transformX(getBaseline());
|
||||
// if (parent->getXAxis()->isLogAxis()) {
|
||||
// if (baseline>0 && baseline>parent->getXAxis()->getMin()) x0=transformX(baseline);
|
||||
// if (getBaseline()>0 && getBaseline()>parent->getXAxis()->getMin()) x0=transformX(getBaseline());
|
||||
// else x0=transformX(parent->getXAxis()->getMin());
|
||||
// }
|
||||
double y0=transformY(baseline);
|
||||
double y0=transformY(getBaseline());
|
||||
if (parent->getYAxis()->isLogAxis()) {
|
||||
y0=transformY(parent->getYAxis()->getMin());
|
||||
if (baseline>0 && baseline>parent->getYAxis()->getMin()) y0=transformY(baseline);
|
||||
if (getBaseline()>0 && getBaseline()>parent->getYAxis()->getMin()) y0=transformY(getBaseline());
|
||||
else y0=transformY(parent->getYAxis()->getMin());
|
||||
}
|
||||
QVector<QLineF> lines;
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
\see JKQTPImpulsesVerticalGraph, \ref JKQTPlotterImpulsePlots
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalGraph: public JKQTPXYGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphSymbolStyleMixin{
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalGraph: public JKQTPXYBaselineGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphSymbolStyleMixin{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
@ -52,11 +52,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalGraph: public JKQTPXYGraph,
|
||||
/*! \brief color of symbols and impulses in one call */
|
||||
virtual void setColor(QColor c);
|
||||
|
||||
/*! \copydoc baseline */
|
||||
void setBaseline(double __value);
|
||||
/*! \copydoc baseline */
|
||||
double getBaseline() const;
|
||||
|
||||
/*! \copydoc drawSymbols */
|
||||
void setDrawSymbols(bool __value);
|
||||
/*! \copydoc drawSymbols */
|
||||
@ -64,11 +59,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalGraph: public JKQTPXYGraph,
|
||||
|
||||
protected:
|
||||
|
||||
/** \brief baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!)
|
||||
*
|
||||
* \image html impulsesplot_baseline.png
|
||||
*/
|
||||
double baseline;
|
||||
/** \brief indicates whether to draw symbols at the top of the impulse
|
||||
*
|
||||
* \image html impulsesplot_symbols.png
|
||||
|
@ -37,11 +37,10 @@
|
||||
|
||||
|
||||
JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter* parent):
|
||||
JKQTPXYGraph(parent)
|
||||
JKQTPXYBaselineGraph(parent)
|
||||
{
|
||||
m_drawSymbols=false;
|
||||
m_specialLineType=JKQTPStepLeft;
|
||||
m_baseline=0;
|
||||
|
||||
parentPlotStyle=-1;
|
||||
initLineStyle(parent, parentPlotStyle);
|
||||
@ -99,15 +98,6 @@ JKQTPSpecialLineType JKQTPSpecialLineHorizontalGraph::getSpecialLineType() const
|
||||
return this->m_specialLineType;
|
||||
}
|
||||
|
||||
void JKQTPSpecialLineHorizontalGraph::setBaseline(double __value)
|
||||
{
|
||||
this->m_baseline = __value;
|
||||
}
|
||||
|
||||
double JKQTPSpecialLineHorizontalGraph::getBaseline() const
|
||||
{
|
||||
return this->m_baseline;
|
||||
}
|
||||
|
||||
void JKQTPSpecialLineHorizontalGraph::setColor(QColor c)
|
||||
{
|
||||
@ -150,10 +140,10 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
// double ystart=-1;
|
||||
//double x0=transformX(0);
|
||||
//if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin());
|
||||
double y0=transformY(m_baseline);
|
||||
double y0=transformY(getBaseline());
|
||||
if (parent->getYAxis()->isLogAxis()) {
|
||||
y0=transformY(parent->getYAxis()->getMin());
|
||||
if (m_baseline>0 && m_baseline>parent->getYAxis()->getMin()) y0=transformY(m_baseline);
|
||||
if (getBaseline()>0 && getBaseline()>parent->getYAxis()->getMin()) y0=transformY(getBaseline());
|
||||
else y0=transformY(parent->getYAxis()->getMin());
|
||||
}
|
||||
bool subsequentItem=false;
|
||||
@ -339,9 +329,9 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
double xold=-1;
|
||||
double yold=-1;
|
||||
double x0=transformX(m_baseline);
|
||||
double x0=transformX(getBaseline());
|
||||
if (parent->getXAxis()->isLogAxis()) {
|
||||
if (m_baseline>0 && m_baseline>parent->getXAxis()->getMin()) x0=transformX(m_baseline);
|
||||
if (getBaseline()>0 && getBaseline()>parent->getXAxis()->getMin()) x0=transformX(getBaseline());
|
||||
else x0=transformX(parent->getXAxis()->getMin());
|
||||
}
|
||||
bool first=false;
|
||||
|
@ -50,7 +50,7 @@ class JKQTPDatastore;
|
||||
|
||||
\see JKQTPSpecialLineVerticalGraph, JKQTPFilledCurveXGraph, \ref JKQTPlotterSpecialStepLinePlot
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYGraph, public JKQTPGraphLineAndFillStyleMixin, public JKQTPGraphSymbolStyleMixin {
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYBaselineGraph, public JKQTPGraphLineAndFillStyleMixin, public JKQTPGraphSymbolStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
@ -74,10 +74,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYGrap
|
||||
void setSpecialLineType(const JKQTPSpecialLineType & __value);
|
||||
/** \brief get the type of connecting (step-)lines */
|
||||
JKQTPSpecialLineType getSpecialLineType() const;
|
||||
/*! sets baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!) */
|
||||
void setBaseline(double __value);
|
||||
/*! returns the baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!) */
|
||||
double getBaseline() const;
|
||||
|
||||
/** \brief set line-color, fill color and symbol color */
|
||||
void setColor(QColor c);
|
||||
protected:
|
||||
@ -86,8 +83,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYGrap
|
||||
bool m_drawSymbols;
|
||||
/** \brief type of connecting (step)lines */
|
||||
JKQTPSpecialLineType m_specialLineType;
|
||||
/** \brief baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!) */
|
||||
double m_baseline;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -972,3 +972,19 @@ bool JKQTPXXYGraph::getIndexRange(int &imin, int &imax) const
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
JKQTPXYBaselineGraph::JKQTPXYBaselineGraph(JKQTBasePlotter *parent):
|
||||
JKQTPXYGraph(parent), m_baseline(0.0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
double JKQTPXYBaselineGraph::getBaseline() const
|
||||
{
|
||||
return m_baseline;
|
||||
}
|
||||
|
||||
void JKQTPXYBaselineGraph::setBaseline(double __value)
|
||||
{
|
||||
m_baseline=__value;
|
||||
}
|
||||
|
@ -638,6 +638,36 @@ protected:
|
||||
|
||||
|
||||
|
||||
/** \brief This virtual JKQTPGraph descendent extends JKQTPXYGraph adds a baseline-property, which is necessary, e.g. for barcharts, filled graphs to indicate until where to draw the bar or fill the curve (default is 0).
|
||||
* \ingroup jkqtplotter_basegraphs
|
||||
*
|
||||
* \see JKQTPSpecialLineHorizontalGraph, JKQTPBarVerticalGraph, JKQTPImpulsesHorizontalGraph, ...
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPXYBaselineGraph: public JKQTPXYGraph {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/** \brief class constructor */
|
||||
JKQTPXYBaselineGraph(JKQTBasePlotter* parent=nullptr);
|
||||
|
||||
/** \copydoc m_baseline */
|
||||
double getBaseline() const;
|
||||
|
||||
Q_PROPERTY(double baseline READ getBaseline WRITE setBaseline)
|
||||
public slots:
|
||||
/** \copydoc m_baseline */
|
||||
void setBaseline(double __value);
|
||||
|
||||
protected:
|
||||
|
||||
/** \brief baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!)
|
||||
*
|
||||
* \image html impulsesplot_baseline.png
|
||||
*/
|
||||
double m_baseline;
|
||||
};
|
||||
|
||||
|
||||
/** \brief This virtual JKQTPGraph descendent extends JKQTPXYGraph to two columns for y-values (e.g. for filled range plots in JKQTPFilledVerticalRangeGraph).
|
||||
* \ingroup jkqtplotter_basegraphs
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user