mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 17:41:39 +08:00
improved/breaking change: reworked class hierarchy of special line (step) graphs
This commit is contained in:
parent
abe1c655ba
commit
d638ff1e9c
@ -28,6 +28,7 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
|
||||
<li>improved/breaking change: reworked class hierarchy of parsed function plots and declared several setters as slots.</li>
|
||||
<li>improved/breaking change: reworked class hierarchy of bar & impulse charts.</li>
|
||||
<li>improved/breaking change: reworked class hierarchy of range charts.</li>
|
||||
<li>improved/breaking change: reworked class hierarchy of special line (step) graphs.</li>
|
||||
<li>improved/breaking change: reworked graph Base-Classes (promoted several setters to slots, added Q_PROPERTY- and Q_ENUM-declarations...)</li>
|
||||
<li>improved/breaking change: made more functions and function parameters const</li>
|
||||
<li>bugfixed/improved: aspect ratio handling in JKQTPlotter.</li>
|
||||
|
@ -34,14 +34,9 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter* parent):
|
||||
JKQTPXYBaselineGraph(parent)
|
||||
JKQTPSpecialLineGraphBase::JKQTPSpecialLineGraphBase(JKQTBasePlotter* parent):
|
||||
JKQTPXYBaselineGraph(parent), m_drawSymbols(false), m_specialLineType(JKQTPStepLeft)
|
||||
{
|
||||
m_drawSymbols=false;
|
||||
m_specialLineType=JKQTPStepLeft;
|
||||
|
||||
parentPlotStyle=-1;
|
||||
initLineStyle(parent, parentPlotStyle);
|
||||
initFillStyle(parent, parentPlotStyle);
|
||||
@ -49,14 +44,7 @@ JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter
|
||||
setFillCurve(false);
|
||||
}
|
||||
|
||||
|
||||
JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTPlotter* parent):
|
||||
JKQTPSpecialLineHorizontalGraph(parent->getPlotter())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void JKQTPSpecialLineHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
|
||||
void JKQTPSpecialLineGraphBase::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
QPen p=getLinePen(painter, parent);
|
||||
QPen np(Qt::NoPen);
|
||||
@ -73,33 +61,34 @@ void JKQTPSpecialLineHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painte
|
||||
|
||||
}
|
||||
|
||||
QColor JKQTPSpecialLineHorizontalGraph::getKeyLabelColor() const {
|
||||
|
||||
QColor JKQTPSpecialLineGraphBase::getKeyLabelColor() const {
|
||||
return getLineColor();
|
||||
}
|
||||
|
||||
void JKQTPSpecialLineHorizontalGraph::setDrawSymbols(bool __value)
|
||||
void JKQTPSpecialLineGraphBase::setDrawSymbols(bool __value)
|
||||
{
|
||||
m_drawSymbols=__value;
|
||||
}
|
||||
|
||||
bool JKQTPSpecialLineHorizontalGraph::getDrawSymbols() const
|
||||
bool JKQTPSpecialLineGraphBase::getDrawSymbols() const
|
||||
{
|
||||
return m_drawSymbols;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPSpecialLineHorizontalGraph::setSpecialLineType(const JKQTPSpecialLineType &__value)
|
||||
void JKQTPSpecialLineGraphBase::setSpecialLineType(const JKQTPSpecialLineType &__value)
|
||||
{
|
||||
this->m_specialLineType = __value;
|
||||
}
|
||||
|
||||
JKQTPSpecialLineType JKQTPSpecialLineHorizontalGraph::getSpecialLineType() const
|
||||
JKQTPSpecialLineType JKQTPSpecialLineGraphBase::getSpecialLineType() const
|
||||
{
|
||||
return this->m_specialLineType;
|
||||
}
|
||||
|
||||
|
||||
void JKQTPSpecialLineHorizontalGraph::setColor(QColor c)
|
||||
void JKQTPSpecialLineGraphBase::setColor(QColor c)
|
||||
{
|
||||
setLineColor(c);
|
||||
setSymbolColor(c);
|
||||
@ -110,6 +99,21 @@ void JKQTPSpecialLineHorizontalGraph::setColor(QColor c)
|
||||
}
|
||||
|
||||
|
||||
|
||||
JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter* parent):
|
||||
JKQTPSpecialLineGraphBase(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
JKQTPSpecialLineHorizontalGraph::JKQTPSpecialLineHorizontalGraph(JKQTPlotter* parent):
|
||||
JKQTPSpecialLineHorizontalGraph(parent->getPlotter())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTPSpecialLineHorizontalGraph::draw");
|
||||
@ -136,10 +140,6 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
double xold=-1;
|
||||
double yold=-1;
|
||||
// double xstart=-1;
|
||||
// double ystart=-1;
|
||||
//double x0=transformX(0);
|
||||
//if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin());
|
||||
double y0=transformY(getBaseline());
|
||||
if (parent->getYAxis()->isLogAxis()) {
|
||||
y0=transformY(parent->getYAxis()->getMin());
|
||||
@ -293,12 +293,12 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
|
||||
JKQTPSpecialLineVerticalGraph::JKQTPSpecialLineVerticalGraph(JKQTBasePlotter *parent):
|
||||
JKQTPSpecialLineHorizontalGraph(parent)
|
||||
JKQTPSpecialLineGraphBase(parent)
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPSpecialLineVerticalGraph::JKQTPSpecialLineVerticalGraph(JKQTPlotter *parent):
|
||||
JKQTPSpecialLineHorizontalGraph(parent)
|
||||
JKQTPSpecialLineVerticalGraph(parent->getPlotter())
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -43,60 +43,82 @@ class JKQTPDatastore;
|
||||
|
||||
|
||||
|
||||
/*! \brief This implements a step plot with values \f$ \left(x, f(x) \right) \f$
|
||||
\ingroup jkqtplotter_linesymbolgraphs_simple
|
||||
|
||||
\image html stepplots.png
|
||||
|
||||
\see JKQTPSpecialLineVerticalGraph, JKQTPFilledCurveXGraph, \ref JKQTPlotterSpecialStepLinePlot
|
||||
/** \brief a Base class for special line graphs (steps ...) like e.g. JKQTPSpecialLineHorizontalGraph
|
||||
* \ingroup jkqtplotter_linesymbolgraphs_simple
|
||||
*
|
||||
* \image html stepplots.png
|
||||
*
|
||||
* \see JKQTPSpecialLineHorizontalGraph, JKQTPSpecialLineVerticalGraph
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPXYBaselineGraph, public JKQTPGraphLineAndFillStyleMixin, public JKQTPGraphSymbolStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
JKQTPSpecialLineHorizontalGraph(JKQTPlotter* parent);
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineGraphBase: public JKQTPXYBaselineGraph, public JKQTPGraphLineAndFillStyleMixin, public JKQTPGraphSymbolStyleMixin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
explicit JKQTPSpecialLineGraphBase(JKQTBasePlotter* parent=nullptr);
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
/** \brief plots a key marker inside the specified rectangle \a rect */
|
||||
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
|
||||
/** \brief returns the color to be used for the key label */
|
||||
virtual QColor getKeyLabelColor() const override;
|
||||
/** \brief returns the color to be used for the key label */
|
||||
virtual QColor getKeyLabelColor() const override;
|
||||
/** \brief plots a key marker inside the specified rectangle \a rect */
|
||||
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) override;
|
||||
|
||||
|
||||
/*! sets whether to draw symbols */
|
||||
void setDrawSymbols(bool __value);
|
||||
/*! returns whether symbols are drawn */
|
||||
bool getDrawSymbols() const;
|
||||
/** \brief set the type of connecting (step-)lines */
|
||||
void setSpecialLineType(const JKQTPSpecialLineType & __value);
|
||||
/** \brief get the type of connecting (step-)lines */
|
||||
JKQTPSpecialLineType getSpecialLineType() const;
|
||||
/** \copydoc m_drawSymbols */
|
||||
bool getDrawSymbols() const;
|
||||
/** \copydoc m_specialLineType */
|
||||
JKQTPSpecialLineType getSpecialLineType() const;
|
||||
|
||||
/** \brief set line-color, fill color and symbol color */
|
||||
void setColor(QColor c);
|
||||
protected:
|
||||
Q_PROPERTY(bool drawSymbols READ getDrawSymbols WRITE setDrawSymbols)
|
||||
Q_PROPERTY(JKQTPSpecialLineType specialLineType READ getSpecialLineType WRITE setSpecialLineType)
|
||||
public slots:
|
||||
/** \brief set line-color, fill color and symbol color */
|
||||
void setColor(QColor c);
|
||||
/** \copydoc m_drawSymbols */
|
||||
void setDrawSymbols(bool __value);
|
||||
/** \copydoc m_specialLineType */
|
||||
void setSpecialLineType(const JKQTPSpecialLineType & __value);
|
||||
protected:
|
||||
|
||||
/** \brief indicates whether to draw a symbols or not */
|
||||
bool m_drawSymbols;
|
||||
/** \brief type of connecting (step)lines */
|
||||
JKQTPSpecialLineType m_specialLineType;
|
||||
/** \brief indicates whether to draw a symbols at the datapoints, or not */
|
||||
bool m_drawSymbols;
|
||||
/** \brief type of connecting (step)lines */
|
||||
JKQTPSpecialLineType m_specialLineType;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** \brief This implements a step plot with values \f$ \left(x, f(x) \right) \f$
|
||||
* \ingroup jkqtplotter_linesymbolgraphs_simple
|
||||
*
|
||||
* \image html stepplots.png
|
||||
*
|
||||
* \see JKQTPSpecialLineVerticalGraph, \ref JKQTPlotterSpecialStepLinePlot
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineHorizontalGraph: public JKQTPSpecialLineGraphBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
JKQTPSpecialLineHorizontalGraph(JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
JKQTPSpecialLineHorizontalGraph(JKQTPlotter* parent);
|
||||
|
||||
/** \brief plots the graph to the plotter object specified as parent */
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief This implements a step plot with values \f$ \left(f(y), y \right) \f$
|
||||
\ingroup jkqtplotter_linesymbolgraphs_simple
|
||||
|
||||
\image html stepplots_vertical.png
|
||||
|
||||
\see JKQTPSpecialLineHorizontalGraph, JKQTPFilledCurveYGraph, \ref JKQTPlotterSpecialStepLinePlot
|
||||
\see JKQTPSpecialLineHorizontalGraph, \ref JKQTPlotterSpecialStepLinePlot
|
||||
*/
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineVerticalGraph: public JKQTPSpecialLineHorizontalGraph {
|
||||
class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineVerticalGraph: public JKQTPSpecialLineGraphBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
|
Loading…
Reference in New Issue
Block a user