#include <QtGui>
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_valuelist.h"
#include "qwt_scale_div.h"
#include "qwt_symbol.h"
#include "qwt_painter.h"
{
public:
{
//painter->translate(r.topLeft());
//shape |_|__
QwtPainter::drawLine(painter, r.
bottomLeft(), r.
topLeft());
QwtPainter::drawLine(painter, r.
bottomLeft(), r.
bottomRight());
QwtPainter::drawLine(painter, r.
right()-r.
width()/2, r.
bottom(),
r.right()-r.width()/2, r.top());
}
};
{
public:
{
rect.
setSize(QwtPainter::metricsMap().
screenToLayout(symbol.
size()));
for (int i = from; i <= to; i++)
{
const int xi = xMap.transform(x(i));
const int yi = yMap.transform(y(i));
rect.
moveCenter(QPoint(xi, yi
));
painter
->setPen
(QPen(Qt
::blue));
feather f;
f.draw(painter, rect);
}
}
};
int main(int argc, char *argv[])
{
qwt
->setCanvasBackground
(QColor(Qt
::white));
//set scale for x-axis
qwt
->setAxisScale
(QwtPlot::xBottom,
13,
0);
qwt
->setAxisMaxMajor
(QwtPlot::xBottom,
24);
qwt
->setAxisMaxMinor
(QwtPlot::xBottom,
0);
//set scale for y-axis
qwt
->setAxisScale
(QwtPlot::yLeft,
0,
31);
//create data for curve
int MAX=12*30;
double x[MAX], y[MAX];
int k=1;
int l=1;
for (int i=0; i<MAX; i++)
{
x[i]=k;
y[i]=l;
k++;
if (k>12)
{
k=1;
l++;
}
}
//create symbol for curve
feather sym;
sym.setSize(30, 10);
//create curve , set symbol and data to curve
curve_data *cur=new curve_data;
cur->setSymbol(sym);
cur->setData(x, y, MAX);
cur->attach(qwt);
qwt->resize(800, 600);
qwt->show();
return a.exec();
}
#include <QtGui>
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_valuelist.h"
#include "qwt_scale_div.h"
#include "qwt_symbol.h"
#include "qwt_painter.h"
class feather : public QwtSymbol
{
public:
void draw(QPainter *painter, const QRect &r) const
{
//painter->translate(r.topLeft());
//shape |_|__
QwtPainter::drawLine(painter, r.bottomLeft(), r.topLeft());
QwtPainter::drawLine(painter, r.bottomLeft(), r.bottomRight());
QwtPainter::drawLine(painter, r.right()-r.width()/2, r.bottom(),
r.right()-r.width()/2, r.top());
}
};
class curve_data : public QwtPlotCurve
{
public:
void drawSymbols(QPainter *painter, const QwtSymbol &symbol,
const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
{
QRect rect;
rect.setSize(QwtPainter::metricsMap().screenToLayout(symbol.size()));
for (int i = from; i <= to; i++)
{
const int xi = xMap.transform(x(i));
const int yi = yMap.transform(y(i));
rect.moveCenter(QPoint(xi, yi));
painter->setPen(QPen(Qt::blue));
feather f;
f.draw(painter, rect);
}
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QwtPlot *qwt =new QwtPlot;
qwt->setCanvasBackground(QColor(Qt::white));
//set scale for x-axis
qwt->setAxisScale(QwtPlot::xBottom, 13, 0);
qwt->setAxisMaxMajor(QwtPlot::xBottom, 24);
qwt->setAxisMaxMinor(QwtPlot::xBottom, 0);
//set scale for y-axis
qwt->setAxisScale(QwtPlot::yLeft, 0, 31);
//create data for curve
int MAX=12*30;
double x[MAX], y[MAX];
int k=1;
int l=1;
for (int i=0; i<MAX; i++)
{
x[i]=k;
y[i]=l;
k++;
if (k>12)
{
k=1;
l++;
}
}
//create symbol for curve
feather sym;
sym.setStyle(QwtSymbol::Cross);
sym.setSize(30, 10);
//create curve , set symbol and data to curve
curve_data *cur=new curve_data;
cur->setStyle(QwtPlotCurve::NoCurve);
cur->setSymbol(sym);
cur->setData(x, y, MAX);
cur->attach(qwt);
qwt->resize(800, 600);
qwt->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks