reworked class hierarchy of impulse graphs

This commit is contained in:
jkriege2 2020-09-19 15:21:33 +02:00
parent d57da36a99
commit 7e425e7bb5
3 changed files with 105 additions and 65 deletions

View File

@ -26,7 +26,7 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
<li>improved/breaking change: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)</li>
<li>improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)</li>
<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 charts.</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 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>

View File

@ -34,15 +34,45 @@
JKQTPImpulsesHorizontalGraph::JKQTPImpulsesHorizontalGraph(JKQTBasePlotter* parent):
JKQTPXYBaselineGraph(parent)
JKQTPImpulsesGraphBase::JKQTPImpulsesGraphBase(JKQTBasePlotter* parent):
JKQTPXYBaselineGraph(parent), drawSymbols(false)
{
drawSymbols=false;
initLineStyle(parent, parentPlotStyle);
initSymbolStyle(parent, parentPlotStyle);
setLineWidth(3);
}
QColor JKQTPImpulsesGraphBase::getKeyLabelColor() const {
return getLineColor();
}
void JKQTPImpulsesGraphBase::setColor(QColor c)
{
setLineColor(c);
setSymbolColor(c);
setSymbolFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphFillColorDerivationMode, c));
c.setAlphaF(0.5);
setHighlightingLineColor(c);
}
void JKQTPImpulsesGraphBase::setDrawSymbols(bool __value)
{
drawSymbols=__value;
}
bool JKQTPImpulsesGraphBase::getDrawSymbols() const
{
return drawSymbols;
}
JKQTPImpulsesHorizontalGraph::JKQTPImpulsesHorizontalGraph(JKQTBasePlotter* parent):
JKQTPImpulsesGraphBase(parent)
{
}
JKQTPImpulsesHorizontalGraph::JKQTPImpulsesHorizontalGraph(JKQTPlotter* parent):
JKQTPImpulsesHorizontalGraph(parent->getPlotter())
{
@ -126,33 +156,11 @@ void JKQTPImpulsesHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter,
QPen p=getLinePen(painter, parent);
p.setCapStyle(Qt::FlatCap);
painter.setPen(p);
int y=rect.top()+rect.height()/2.0;
const int y=rect.top()+rect.height()/2.0;
painter.drawLine(rect.left(), y, rect.right(), y);
}
QColor JKQTPImpulsesHorizontalGraph::getKeyLabelColor() const {
return getLineColor();
}
void JKQTPImpulsesHorizontalGraph::setColor(QColor c)
{
setLineColor(c);
setSymbolColor(c);
setSymbolFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphFillColorDerivationMode, c));
c.setAlphaF(0.5);
setHighlightingLineColor(c);
}
void JKQTPImpulsesHorizontalGraph::setDrawSymbols(bool __value)
{
drawSymbols=__value;
}
bool JKQTPImpulsesHorizontalGraph::getDrawSymbols() const
{
return drawSymbols;
}
@ -165,16 +173,28 @@ bool JKQTPImpulsesHorizontalGraph::getDrawSymbols() const
JKQTPImpulsesVerticalGraph::JKQTPImpulsesVerticalGraph(JKQTBasePlotter* parent):
JKQTPImpulsesHorizontalGraph(parent)
JKQTPImpulsesGraphBase(parent)
{
}
JKQTPImpulsesVerticalGraph::JKQTPImpulsesVerticalGraph(JKQTPlotter *parent):
JKQTPImpulsesHorizontalGraph(parent)
JKQTPImpulsesVerticalGraph(parent->getPlotter())
{
}
void JKQTPImpulsesVerticalGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QPen p=getLinePen(painter, parent);
p.setCapStyle(Qt::FlatCap);
painter.setPen(p);
const int x=rect.left()+rect.width()/2.0;
painter.drawLine(x, rect.bottom(), x, rect.top());
}
void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
#ifdef JKQTBP_AUTOTIMER
JKQTPAutoOutputTimer jkaaot("JKQTPImpulsesVerticalGraph::draw");

View File

@ -27,53 +27,71 @@
/*! \brief This implements an impulse plot with impulses in direction of the X axis (i.e. from y=0 to y=f(x) )
\ingroup jkqtplotter_barssticks
\image html plot_impulsesxplots.png
\see JKQTPImpulsesVerticalGraph, \ref JKQTPlotterImpulsePlots
/** \brief This is a base class for all impulse graphs
* \ingroup jkqtplotter_barssticks
*
* \see JKQTPImpulsesHorizontalGraph, JKQTPImpulsesVerticalGraph
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalGraph: public JKQTPXYBaselineGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphSymbolStyleMixin{
Q_OBJECT
public:
/** \brief class constructor */
JKQTPImpulsesHorizontalGraph(JKQTBasePlotter* parent=nullptr);
/** \brief class constructor */
JKQTPImpulsesHorizontalGraph(JKQTPlotter* parent);
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesGraphBase: public JKQTPXYBaselineGraph, public JKQTPGraphLineStyleMixin, public JKQTPGraphSymbolStyleMixin{
Q_OBJECT
public:
/** \brief class constructor */
JKQTPImpulsesGraphBase(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 color of symbols and impulses in one call */
virtual void setColor(QColor c);
/** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor() const override;
/*! \copydoc drawSymbols */
bool getDrawSymbols() const;
/*! \copydoc drawSymbols */
void setDrawSymbols(bool __value);
/*! \copydoc drawSymbols */
bool getDrawSymbols() const;
public slots:
/*! \brief color of symbols and impulses in one call */
virtual void setColor(QColor c);
protected:
/*! \copydoc drawSymbols */
void setDrawSymbols(bool __value);
/** \brief indicates whether to draw symbols at the top of the impulse
protected:
/** \brief indicates whether to draw symbols at the top of the impulse
*
* \image html impulsesplot_symbols.png
*/
bool drawSymbols;
bool drawSymbols;
};
/** \brief This implements an impulse plot with impulses in direction of the X axis (i.e. from y=0 to y=f(x) )
* \ingroup jkqtplotter_barssticks
*
* \image html plot_impulsesxplots.png
*
* \see JKQTPImpulsesVerticalGraph, \ref JKQTPlotterImpulsePlots
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalGraph: public JKQTPImpulsesGraphBase {
Q_OBJECT
public:
/** \brief class constructor */
JKQTPImpulsesHorizontalGraph(JKQTBasePlotter* parent=nullptr);
/** \brief class constructor */
JKQTPImpulsesHorizontalGraph(JKQTPlotter* parent);
/** \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;
protected:
};
/*! \brief This implements an impulse plot with impulses in direction of the X axis (i.e. from x=0 to x=f(y) )
\ingroup jkqtplotter_barssticks
\image html plot_impulsesxerrorsplots.png
\see jkqtpstatAddXErrorImpulsesGraph(), JKQTPImpulsesHorizontalGraph, \ref JKQTPlotterImpulsePlots
/** \brief This implements an impulse plot with impulses in direction of the X axis (i.e. from x=0 to x=f(y) )
* \ingroup jkqtplotter_barssticks
*
* \image html plot_impulsesxerrorsplots.png
*
* \see jkqtpstatAddXErrorImpulsesGraph(), JKQTPImpulsesHorizontalGraph, \ref JKQTPlotterImpulsePlots
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalErrorGraph: public JKQTPImpulsesHorizontalGraph, public JKQTPXGraphErrors {
Q_OBJECT
@ -100,7 +118,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesHorizontalErrorGraph: public JKQTPImpu
\see \ref JKQTPlotterImpulsePlots
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesVerticalGraph: public JKQTPImpulsesHorizontalGraph {
class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesVerticalGraph: public JKQTPImpulsesGraphBase {
Q_OBJECT
public:
/** \brief class constructor */
@ -110,6 +128,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPImpulsesVerticalGraph: public JKQTPImpulsesHor
/** \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;
};