diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index a0675c8a72..017226cc22 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -26,7 +26,7 @@ Changes, compared to \ref page_whatsnew_V2019_11 "v2019.11" include:
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)
improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
improved/breaking change: reworked class hierarchy of parsed function plots and declared several setters as slots.
- improved/breaking change: reworked class hierarchy of bar charts.
+ improved/breaking change: reworked class hierarchy of bar & impulse charts.
improved/breaking change: reworked class hierarchy of range charts.
improved/breaking change: reworked graph Base-Classes (promoted several setters to slots, added Q_PROPERTY- and Q_ENUM-declarations...)
improved/breaking change: made more functions and function parameters const
diff --git a/lib/jkqtplotter/graphs/jkqtpimpulses.cpp b/lib/jkqtplotter/graphs/jkqtpimpulses.cpp
index 6ed3a1fb65..7a24469f51 100644
--- a/lib/jkqtplotter/graphs/jkqtpimpulses.cpp
+++ b/lib/jkqtplotter/graphs/jkqtpimpulses.cpp
@@ -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");
diff --git a/lib/jkqtplotter/graphs/jkqtpimpulses.h b/lib/jkqtplotter/graphs/jkqtpimpulses.h
index 0e38dbf8c2..361fa99178 100644
--- a/lib/jkqtplotter/graphs/jkqtpimpulses.h
+++ b/lib/jkqtplotter/graphs/jkqtpimpulses.h
@@ -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;
};