##// END OF EJS Templates
Refactor xyplotdata...
Refactor xyplotdata * rename xyplotdata to xyplotdomain * add proper initialization list to constructor * change xylinechartitem update interface

File last commit:

r25:9ee7e26e06fe
r25:9ee7e26e06fe
Show More
xygrid.cpp
70 lines | 1.8 KiB | text/x-c | CppLexer
Michal Klocek
adds missing files form previous commit
r12 #include "xygrid_p.h"
#include <QPainter>
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include <QDebug>
Michal Klocek
adds missing files form previous commit
r12
QCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor current draft to fit int current design specs...
r21 XYGrid::XYGrid(QGraphicsItem* parent):QGraphicsItem(parent)
Michal Klocek
adds missing files form previous commit
r12 {
}
XYGrid::~XYGrid()
{
// TODO Auto-generated destructor stub
}
Michal Klocek
Refactor current draft to fit int current design specs...
r21 void XYGrid::setSize(const QSizeF& size)
{
Michal Klocek
adds missing files form previous commit
r12 m_rect.setSize(size.toSize());
}
Michal Klocek
Refactor xyplotdata...
r25 void XYGrid::setXYPlotData(const XYPlotDomain& xyPlotData)
Michal Klocek
Refactor current draft to fit int current design specs...
r21 {
m_xyPlotData = xyPlotData;
}
Michal Klocek
adds missing files form previous commit
r12
QRectF XYGrid::boundingRect() const
{
return m_rect;
}
void XYGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
{
Michal Klocek
Refactor current draft to fit int current design specs...
r21 if (!m_rect.isValid())
return;
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 const qreal deltaX = (m_rect.width() -1) / m_xyPlotData.ticksX();
const qreal deltaY = (m_rect.height() - 1) / m_xyPlotData.ticksY();
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 for (int i = 0; i <= m_xyPlotData.ticksX(); ++i) {
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 int x = i * deltaX + m_rect.left();
qreal label = m_xyPlotData.m_minX + (i * m_xyPlotData.spanX()
/ m_xyPlotData.ticksX());
painter->drawLine(x, m_rect.top()+1, x, m_rect.bottom());
//painter->drawLine(x, m_rect.bottom(), x, m_rect.bottom() + 5);
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 painter->drawText(x - 50, m_rect.bottom() + 5, 100, 20,
Qt::AlignHCenter | Qt::AlignTop,
QString::number(label));
}
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 for (int j = 0; j <= m_xyPlotData.ticksY(); ++j) {
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 int y = j * -deltaY + m_rect.bottom();
qreal label = m_xyPlotData.m_minY + (j * m_xyPlotData.spanY()
/ m_xyPlotData.ticksY());
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 painter->drawLine(m_rect.left(), y, m_rect.right()-1, y);
//painter->drawLine(m_rect.left() - 5, y, m_rect.left(), y);
//TODO : margin = 50 ;
painter->drawText(m_rect.left() - 50, y - 10, 50 - 5, 20,
Qt::AlignRight | Qt::AlignVCenter,
QString::number(label));
}
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactor current draft to fit int current design specs...
r21 //painter->drawRect(m_rect.adjusted(0, 0, -1, -1));
Michal Klocek
adds missing files form previous commit
r12 }
QCHART_END_NAMESPACE