jmsbc
11th April 2009, 01:56
Hi,
I needed to inherit from qwt_plot_curve to add another CurveStyle (DottedLines) to the enum:
/*
- UserCurve
Styles >= UserCurve are reserved for derived
classes of QwtPlotCurve that overload drawCurve() with
additional application specific curve types.
*/
enum CurveStyle
{
NoCurve,
Lines,
Sticks,
Steps,
Dots,
UserCurve = 100
};
I wanted to make a style called DottedLine, which connects every other point with a line. I need to derive a class and then redefine DrawCurve:
void QwtPlotCurve::drawCurve(QPainter *painter, int style,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
int from, int to) const
{
switch (style)
{
case Lines:
if ( testCurveAttribute(Fitted) )
{
// we always need the complete
// curve for fitting
from = 0;
to = dataSize() - 1;
}
drawLines(painter, xMap, yMap, from, to);
break;
case Sticks:
drawSticks(painter, xMap, yMap, from, to);
break;
case Steps:
drawSteps(painter, xMap, yMap, from, to);
break;
case Dots:
drawDots(painter, xMap, yMap, from, to);
break;
case DottedLines:
drawDottedLines(painter, xMap, yMap, from, to);
break;
case NoCurve:
default:
break;
}
}
(I added drawDottedLines at the bottom). How can I inherit the enum CurveStyles such that I can set the style using:
void QwtPlotCurve::setStyle(CurveStyle style)?
I can't inherit the enum right? Do I need to redefine setStyle to:
void MyPlotCurve::setStyle(MyCurveStyle style)? And if so, how do I define MyCurveStyle?
I hope this is not too confusing, thanks
I needed to inherit from qwt_plot_curve to add another CurveStyle (DottedLines) to the enum:
/*
- UserCurve
Styles >= UserCurve are reserved for derived
classes of QwtPlotCurve that overload drawCurve() with
additional application specific curve types.
*/
enum CurveStyle
{
NoCurve,
Lines,
Sticks,
Steps,
Dots,
UserCurve = 100
};
I wanted to make a style called DottedLine, which connects every other point with a line. I need to derive a class and then redefine DrawCurve:
void QwtPlotCurve::drawCurve(QPainter *painter, int style,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
int from, int to) const
{
switch (style)
{
case Lines:
if ( testCurveAttribute(Fitted) )
{
// we always need the complete
// curve for fitting
from = 0;
to = dataSize() - 1;
}
drawLines(painter, xMap, yMap, from, to);
break;
case Sticks:
drawSticks(painter, xMap, yMap, from, to);
break;
case Steps:
drawSteps(painter, xMap, yMap, from, to);
break;
case Dots:
drawDots(painter, xMap, yMap, from, to);
break;
case DottedLines:
drawDottedLines(painter, xMap, yMap, from, to);
break;
case NoCurve:
default:
break;
}
}
(I added drawDottedLines at the bottom). How can I inherit the enum CurveStyles such that I can set the style using:
void QwtPlotCurve::setStyle(CurveStyle style)?
I can't inherit the enum right? Do I need to redefine setStyle to:
void MyPlotCurve::setStyle(MyCurveStyle style)? And if so, how do I define MyCurveStyle?
I hope this is not too confusing, thanks