##// END OF EJS Templates
Integrated scatter series...
Integrated scatter series Also implemented optional drawing algorithm of series that uses only paint method of QGraphicsItems.

File last commit:

r38:67e4c740a645
r38:67e4c740a645
Show More
qchartwidget.cpp
76 lines | 1.8 KiB | text/x-c | CppLexer
/ src / qchartwidget.cpp
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 #include "qchartwidget.h"
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include "qchartseries.h"
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 #include <QGraphicsView>
#include <QGraphicsScene>
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include <QResizeEvent>
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19
class QChartWidgetPrivate
{
public:
Michal Klocek
Refactor current draft to fit int current design specs...
r21 QChartWidgetPrivate(QChartWidget *parent) :
m_view(0),
m_scene(0),
Michal Klocek
Adds pimpl to qchart class
r28 m_chart(0)
Michal Klocek
Refactor current draft to fit int current design specs...
r21 {
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 m_scene = new QGraphicsScene();
Michal Klocek
Refactor current draft to fit int current design specs...
r21 m_view = new QGraphicsView(parent);
m_view->setScene(m_scene);
m_chart = new QChart();
m_scene->addItem(m_chart);
Tero Ahola
Integrated scatter series...
r38 m_view->show();
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 }
Michal Klocek
Refactor current draft to fit int current design specs...
r21
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 ~QChartWidgetPrivate() {
}
QGraphicsView *m_view;
QGraphicsScene *m_scene;
QChart* m_chart;
};
Tero Ahola
Added size hint for the widget
r29 ///////////////////////////////////////////////////////////////////////////////////////////////////
Michal Klocek
Adds pimpl to qchart class
r28
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 QChartWidget::QChartWidget(QWidget *parent) :
QWidget(parent),
Michal Klocek
Refactor current draft to fit int current design specs...
r21 d_ptr(new QChartWidgetPrivate(this))
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 {
Tero Ahola
Added size hint for the widget
r29 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 }
QChartWidget::~QChartWidget()
{
Michal Klocek
Refactor current draft to fit int current design specs...
r21 delete d_ptr;
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 }
Michal Klocek
Refactor current draft to fit int current design specs...
r21 void QChartWidget::resizeEvent(QResizeEvent *event)
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 {
Michal Klocek
Refactor current draft to fit int current design specs...
r21 Q_D(QChartWidget);
d->m_view->resize(size().width(),size().height());
d->m_scene->setSceneRect(0,0,size().width(),size().height());
d->m_chart->setSize(size());
QWidget::resizeEvent(event);
}
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19
Tero Ahola
Added size hint for the widget
r29 QSize QChartWidget::sizeHint() const
{
// TODO: calculate size hint based on contents?
return QSize(100, 100);
}
Michal Klocek
Refactor current draft to fit int current design specs...
r21
void QChartWidget::addSeries(QChartSeries* series)
{
Q_D(QChartWidget);
d->m_chart->addSeries(series);
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 }
Tero Ahola
Integrated scatter series...
r38 QChartSeries* QChartWidget::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type)
{
Q_D(QChartWidget);
return d->m_chart->createSeries(x, y, type);
}
Tero Ahola
Started to refactor the API to allow integrating different plot types
r19 #include "moc_qchartwidget.cpp"
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE