JKQTPlotter: NEW: added JKQTPXYGraph::setKeyColumn()/JKQTPXYGraph::getKeyColumn() and JKQTPXYGraph::setValueColumn()/JKQTPXYGraph::getValueColumn() and corresponding functions in other classes.

This commit is contained in:
jkriege2 2022-09-10 13:38:29 +02:00
parent a529a33918
commit f11a98779e
9 changed files with 146 additions and 3 deletions

View File

@ -46,6 +46,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>NEW: added the option to draw a character from a font as symbol (<code>JKQTPCharacterSymbol+QChar('C').unicode()</code> and <code>JKQTPFilledCharacterSymbol+QChar('C').unicode()</code>)</li> <li>NEW: added the option to draw a character from a font as symbol (<code>JKQTPCharacterSymbol+QChar('C').unicode()</code> and <code>JKQTPFilledCharacterSymbol+QChar('C').unicode()</code>)</li>
<li>NEW: added the option to register a custom symbol using JKQTPRegisterCustomGraphSymbol() </li> <li>NEW: added the option to register a custom symbol using JKQTPRegisterCustomGraphSymbol() </li>
<li>NEW: added property drawLineInForeground to JKQTPXYLineGraph and JKQTPXYParametrizedScatterGraph</li> <li>NEW: added property drawLineInForeground to JKQTPXYLineGraph and JKQTPXYParametrizedScatterGraph</li>
<li>NEW: added JKQTPXYGraph::setKeyColumn()/JKQTPXYGraph::getKeyColumn() and JKQTPXYGraph::setValueColumn()/JKQTPXYGraph::getValueColumn() and corresponding functions in other classes. In most graph classes they point to xColumn for key and yColumn for values. These functions are virtual and overwritten in derived classes with horizontally oriented graphs, where they point to yColumn for key and yColumn for value. This way you can write generic code with classes for both orientations.</li>
</ul></li> </ul></li>
<li>JKQTMathText:<ul> <li>JKQTMathText:<ul>

View File

@ -199,6 +199,26 @@ int JKQTPBarHorizontalGraph::getBarHeightColumn() const
return xColumn; return xColumn;
} }
int JKQTPBarHorizontalGraph::getKeyColumn() const
{
return getBarPositionColumn();
}
int JKQTPBarHorizontalGraph::getValueColumn() const
{
return getBarHeightColumn();
}
void JKQTPBarHorizontalGraph::setKeyColumn(int __value)
{
setBarPositionColumn(__value);
}
void JKQTPBarHorizontalGraph::setValueColumn(int __value)
{
setBarHeightColumn(__value);
}
void JKQTPBarHorizontalGraph::setBarPositionColumn(int column) void JKQTPBarHorizontalGraph::setBarPositionColumn(int column)
{ {
yColumn=column; yColumn=column;

View File

@ -194,7 +194,15 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPBarHorizontalGraph: public JKQTPBarGraphBase {
/** \brief returns xColumn or yColumn, whichever is used for the height of the bars (depending on whether the barchart is vertical or horizontal \see getBarPositionColumn(), xColumn, yColumn */ /** \brief returns xColumn or yColumn, whichever is used for the height of the bars (depending on whether the barchart is vertical or horizontal \see getBarPositionColumn(), xColumn, yColumn */
virtual int getBarHeightColumn() const override; virtual int getBarHeightColumn() const override;
/** \brief returns the column used as "key" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getKeyColumn() const override;
/** \brief returns the column used as "value" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getValueColumn() const override;
public slots: public slots:
/** \brief sets the column used as "key" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setKeyColumn(int __value) override;
/** \brief sets the column used as "value" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setValueColumn(int __value) override;
/** \brief sets xColumn or yColumn, whichever is used for the position of the bars (depending on whether the barchart is vertical or horizontal \see getBarHeightColumn(), xColumn, yColumn */ /** \brief sets xColumn or yColumn, whichever is used for the position of the bars (depending on whether the barchart is vertical or horizontal \see getBarHeightColumn(), xColumn, yColumn */
virtual void setBarPositionColumn(int column) override; virtual void setBarPositionColumn(int column) override;

View File

@ -333,6 +333,26 @@ void JKQTPFilledCurveYGraph::draw(JKQTPEnhancedPainter &painter)
drawErrorsAfter(painter); drawErrorsAfter(painter);
} }
int JKQTPFilledCurveYGraph::getKeyColumn() const
{
return getYColumn();
}
int JKQTPFilledCurveYGraph::getValueColumn() const
{
return getXColumn();
}
void JKQTPFilledCurveYGraph::setKeyColumn(int __value)
{
setYColumn(__value);
}
void JKQTPFilledCurveYGraph::setValueColumn(int __value)
{
setXColumn(__value);
}
JKQTPFilledCurveXErrorGraph::JKQTPFilledCurveXErrorGraph(JKQTBasePlotter *parent): JKQTPFilledCurveXErrorGraph::JKQTPFilledCurveXErrorGraph(JKQTBasePlotter *parent):

View File

@ -68,7 +68,7 @@ public slots:
/** \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);
/** \copydoc m_fillMode */ /** \copydoc m_fillMode */
void setFillMode(FillMode mode); void setFillMode(JKQTPFilledCurveGraphBase::FillMode mode);
protected: protected:
/** \brief specifies how the area of the graph is filles */ /** \brief specifies how the area of the graph is filles */
FillMode m_fillMode; FillMode m_fillMode;
@ -107,7 +107,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveXGraph: public JKQTPFilledCurveGrap
/** \brief class constructor */ /** \brief class constructor */
JKQTPFilledCurveXGraph(JKQTPlotter* parent); JKQTPFilledCurveXGraph(JKQTPlotter* parent);
/** \brief plots the graph to the plotter object specified as parent */ /** \brief plots the graph to the plotter object specified as parent */
void draw(JKQTPEnhancedPainter &painter); void draw(JKQTPEnhancedPainter &painter) override;
}; };
@ -170,7 +170,16 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveYGraph: public JKQTPFilledCurveGrap
JKQTPFilledCurveYGraph(JKQTPlotter* parent); JKQTPFilledCurveYGraph(JKQTPlotter* parent);
/** \brief plots the graph to the plotter object specified as parent */ /** \brief plots the graph to the plotter object specified as parent */
void draw(JKQTPEnhancedPainter &painter); void draw(JKQTPEnhancedPainter &painter) override;
/** \brief returns the column used as "key" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getKeyColumn() const override;
/** \brief returns the column used as "value" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getValueColumn() const override;
public slots:
/** \brief sets the column used as "key" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setKeyColumn(int __value) override;
/** \brief sets the column used as "value" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setValueColumn(int __value) override;
}; };

View File

@ -488,6 +488,26 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
drawErrorsAfter(painter); drawErrorsAfter(painter);
} }
int JKQTPSpecialLineVerticalGraph::getKeyColumn() const
{
return getYColumn();
}
int JKQTPSpecialLineVerticalGraph::getValueColumn() const
{
return getXColumn();
}
void JKQTPSpecialLineVerticalGraph::setKeyColumn(int __value)
{
setYColumn(__value);
}
void JKQTPSpecialLineVerticalGraph::setValueColumn(int __value)
{
setXColumn(__value);
}

View File

@ -128,6 +128,15 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPSpecialLineVerticalGraph: public JKQTPSpecialL
/** \brief plots the graph to the plotter object specified as parent */ /** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter) override; virtual void draw(JKQTPEnhancedPainter& painter) override;
/** \brief returns the column used as "key" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getKeyColumn() const override;
/** \brief returns the column used as "value" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getValueColumn() const override;
public slots:
/** \brief sets the column used as "key" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setKeyColumn(int __value) override;
/** \brief sets the column used as "value" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setValueColumn(int __value) override;
}; };

View File

@ -390,6 +390,16 @@ void JKQTPXYGraph::setYColumn(size_t __value) {
this->yColumn = static_cast<int>(__value); this->yColumn = static_cast<int>(__value);
} }
void JKQTPXYGraph::setKeyColumn(int __value)
{
setXColumn(__value);
}
void JKQTPXYGraph::setValueColumn(int __value)
{
setYColumn(__value);
}
void JKQTPXYGraph::setDataSortOrder(JKQTPXYGraph::DataSortOrder __value) void JKQTPXYGraph::setDataSortOrder(JKQTPXYGraph::DataSortOrder __value)
{ {
this->sortData = __value; this->sortData = __value;
@ -400,6 +410,16 @@ JKQTPXYGraph::DataSortOrder JKQTPXYGraph::getDataSortOrder() const
return this->sortData; return this->sortData;
} }
int JKQTPXYGraph::getKeyColumn() const
{
return getXColumn();
}
int JKQTPXYGraph::getValueColumn() const
{
return getYColumn();
}
void JKQTPXYGraph::setDataSortOrder(int __value) { void JKQTPXYGraph::setDataSortOrder(int __value) {
sortData=static_cast<DataSortOrder>(__value); sortData=static_cast<DataSortOrder>(__value);
} }
@ -822,6 +842,16 @@ void JKQTPXYYGraph::setYColumn2(size_t __value)
yColumn2=static_cast<int>(__value); yColumn2=static_cast<int>(__value);
} }
int JKQTPXYYGraph::getValue2Column() const
{
return getYColumn2();
}
void JKQTPXYYGraph::setValue2Column(int __value)
{
setYColumn2(__value);
}
bool JKQTPXYYGraph::getIndexRange(int &imin, int &imax) const bool JKQTPXYYGraph::getIndexRange(int &imin, int &imax) const
{ {
bool ok=JKQTPXYGraph::getIndexRange(imin, imax); bool ok=JKQTPXYGraph::getIndexRange(imin, imax);
@ -895,6 +925,16 @@ int JKQTPXXYGraph::getXColumn2() const
return xColumn2; return xColumn2;
} }
int JKQTPXXYGraph::getKey2Column() const
{
return getXColumn2();
}
void JKQTPXXYGraph::setKey2Column(int __value)
{
setXColumn2(__value);
}
double JKQTPXXYGraph::hitTest(const QPointF &posSystem, QPointF *closestSpotSystem, QString *label, JKQTPPlotElement::HitTestMode mode) const double JKQTPXXYGraph::hitTest(const QPointF &posSystem, QPointF *closestSpotSystem, QString *label, JKQTPPlotElement::HitTestMode mode) const
{ {
if (parent==nullptr) return JKQTP_NAN; if (parent==nullptr) return JKQTP_NAN;

View File

@ -579,6 +579,10 @@ public:
int getYColumn() const; int getYColumn() const;
/** \copydoc sortData */ /** \copydoc sortData */
DataSortOrder getDataSortOrder() const; DataSortOrder getDataSortOrder() const;
/** \brief returns the column used as "key" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getKeyColumn() const;
/** \brief returns the column used as "value" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getValueColumn() const;
Q_PROPERTY(DataSortOrder sortData READ getDataSortOrder WRITE setDataSortOrder) Q_PROPERTY(DataSortOrder sortData READ getDataSortOrder WRITE setDataSortOrder)
Q_PROPERTY(int xColumn READ getXColumn WRITE setXColumn) Q_PROPERTY(int xColumn READ getXColumn WRITE setXColumn)
@ -622,6 +626,10 @@ public slots:
void setYColumn(int __value); void setYColumn(int __value);
/** \copydoc yColumn */ /** \copydoc yColumn */
void setYColumn (size_t __value); void setYColumn (size_t __value);
/** \brief sets the column used as "key" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setKeyColumn(int __value);
/** \brief sets the column used as "value" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setValueColumn(int __value);
protected: protected:
/** \brief the column that contains the x-component of the datapoints */ /** \brief the column that contains the x-component of the datapoints */
@ -712,6 +720,8 @@ public:
/** \copydoc yColumn2 */ /** \copydoc yColumn2 */
int getYColumn2() const; int getYColumn2() const;
/** \brief returns the column used as secondary "value" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getValue2Column() const;
/** \copydoc JKQTPXYGraph::hitTest() */ /** \copydoc JKQTPXYGraph::hitTest() */
virtual double hitTest(const QPointF &posSystem, QPointF* closestSpotSystem=nullptr, QString* label=nullptr, HitTestMode mode=HitTestXY) const override; virtual double hitTest(const QPointF &posSystem, QPointF* closestSpotSystem=nullptr, QString* label=nullptr, HitTestMode mode=HitTestXY) const override;
@ -728,6 +738,8 @@ public slots:
void setYColumn2(int __value); void setYColumn2(int __value);
/** \copydoc yColumn2 */ /** \copydoc yColumn2 */
void setYColumn2(size_t __value); void setYColumn2(size_t __value);
/** \brief sets the column used as secondary "value" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setValue2Column(int __value);
protected: protected:
/** \brief the column that contains the second y-component of the datapoints */ /** \brief the column that contains the second y-component of the datapoints */
@ -769,6 +781,8 @@ public:
/** \copydoc xColumn2 */ /** \copydoc xColumn2 */
int getXColumn2() const; int getXColumn2() const;
/** \brief returns the column used as "key" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
virtual int getKey2Column() const;
/** \copydoc JKQTPXYGraph::hitTest() */ /** \copydoc JKQTPXYGraph::hitTest() */
virtual double hitTest(const QPointF &posSystem, QPointF* closestSpotSystem=nullptr, QString* label=nullptr, HitTestMode mode=HitTestXY) const override; virtual double hitTest(const QPointF &posSystem, QPointF* closestSpotSystem=nullptr, QString* label=nullptr, HitTestMode mode=HitTestXY) const override;
@ -785,6 +799,8 @@ public slots:
void setXColumn2(int __value); void setXColumn2(int __value);
/** \copydoc xColumn2 */ /** \copydoc xColumn2 */
void setXColumn2(size_t __value); void setXColumn2(size_t __value);
/** \brief sets the column used as "key" for the current graph (typically this call setXColumn(), but for horizontal graphs like filled curves or barcharts it may call setYColumn() ) */
virtual void setKey2Column(int __value);
protected: protected:
/** \brief the column that contains the second y-component of the datapoints */ /** \brief the column that contains the second y-component of the datapoints */