##// END OF EJS Templates
legend layouting change
legend layouting change

File last commit:

r616:4f2467dfeb41
r616:4f2467dfeb41
Show More
qchart.cpp
363 lines | 8.9 KiB | text/x-c | CppLexer
Michal Klocek
adds missing files form previous commit
r12 #include "qchart.h"
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 #include "qchartaxis.h"
sauimone
framework for legend
r524 #include "qlegend.h"
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "chartpresenter_p.h"
#include "chartdataset_p.h"
Tero Ahola
Integrated scatter type series...
r42 #include <QGraphicsScene>
Michal Klocek
Adds layout support for charts....
r115 #include <QGraphicsSceneResizeEvent>
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include <QDebug>
Michal Klocek
adds missing files form previous commit
r12
Marek Rosa
Added some more documentation to QChart and QChartView
r277 QTCOMMERCIALCHART_BEGIN_NAMESPACE
/*!
\enum QChart::ChartTheme
This enum describes the theme used by the chart.
Tero Ahola
Added draft of dark blue theme
r581 \value ChartThemeDefault Follows the GUI style of the Operating System
Marek Rosa
Added some more documentation to QChart and QChartView
r277 \value ChartThemeVanilla
\value ChartThemeIcy
\value ChartThemeGrayscale
\value ChartThemeScientific
Tero Ahola
Added draft of dark blue theme
r581 \value ChartThemeBlueCerulean
Tero Ahola
New theme with light colors, chartview background
r584 \value ChartThemeLight
Tero Ahola
Added draft of dark blue theme
r581 \value ChartThemeCount Not really a theme; the total count of themes.
Marek Rosa
Added some more documentation to QChart and QChartView
r277 */
Tero Ahola
QDoc for animation options in QChart
r302 /*!
\enum QChart::AnimationOption
For enabling/disabling animations. Defaults to NoAnimation.
\value NoAnimation
\value GridAxisAnimations
\value SeriesAnimations
\value AllAnimations
*/
Tero Ahola
Started documenting QChart
r264 /*!
\class QChart
\brief QtCommercial chart API.
QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
representation of different types of QChartSeries and other chart related objects like
QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
convenience class QChartView instead of QChart.
Marek Rosa
Added some documentation to QChart and QChartView
r274 \sa QChartView
Tero Ahola
Started documenting QChart
r264 */
/*!
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
Tero Ahola
Started documenting QChart
r264 */
Michal Klocek
Adds layout support for charts....
r115 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
Tero Ahola
Started documenting QChart
r264 m_backgroundItem(0),
m_titleItem(0),
Tero Ahola
Enabled legend again; it is now created before presenter
r550 m_legend(new QLegend(this)),
Tero Ahola
Started documenting QChart
r264 m_dataset(new ChartDataSet(this)),
sauimone
background to legend, theme applies
r540 m_presenter(new ChartPresenter(this,m_dataset))
Michal Klocek
adds missing files form previous commit
r12 {
Tero Ahola
Enabled legend again; it is now created before presenter
r550 connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
Michal Klocek
adds missing files form previous commit
r12 }
Tero Ahola
Started documenting QChart
r264 /*!
Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
*/
QChart::~QChart()
{
Tero Ahola
Enabled legend again; it is now created before presenter
r550 disconnect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
disconnect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
Tero Ahola
Started documenting QChart
r264 }
Michal Klocek
adds missing files form previous commit
r12
Tero Ahola
Started documenting QChart
r264 /*!
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
Tero Ahola
Started documenting QChart
r264 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
the y axis).
*/
Michal Klocek
Rename QChartSeries to QSeries
r360 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
Michal Klocek
Refactors axis handling...
r223 {
Tero Ahola
Started documenting QChart
r264 m_dataset->addSeries(series, axisY);
Michal Klocek
Refactors axis handling...
r223 }
Tero Ahola
Integrated scatter type series...
r42
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 Removes the \a series specified in a perameter from the QChartView.
Marek Rosa
Added some documentation to QChart and QChartView
r274 It releses its ownership of the specified QChartSeries object.
It does not delete the pointed QChartSeries data object
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 \sa addSeries(), removeAllSeries()
Marek Rosa
Added some documentation to QChart and QChartView
r274 */
Michal Klocek
Rename QChartSeries to QSeries
r360 void QChart::removeSeries(QSeries* series)
Michal Klocek
Refactors axis handling...
r223 {
m_dataset->removeSeries(series);
Tero Ahola
Integrated scatter type series...
r42 }
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Removes all the QChartSeries that have been added to the QChartView
It also deletes the pointed QChartSeries data objects
\sa addSeries(), removeSeries()
*/
Michal Klocek
Adds RemoveAllSeries method to API
r258 void QChart::removeAllSeries()
{
m_dataset->removeAllSeries();
}
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Sets the \a brush that is used for painting the background of the chart area.
*/
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 void QChart::setChartBackgroundBrush(const QBrush& brush)
{
Michal Klocek
Refactors axis handling...
r223 createChartBackgroundItem();
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 m_backgroundItem->setBrush(brush);
m_backgroundItem->update();
}
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Sets the \a pen that is used for painting the background of the chart area.
*/
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 void QChart::setChartBackgroundPen(const QPen& pen)
{
Michal Klocek
Refactors axis handling...
r223 createChartBackgroundItem();
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 m_backgroundItem->setPen(pen);
m_backgroundItem->update();
}
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Michal Klocek
Fixes for docs , adds xyseries docs
r481 Sets the chart \a title. The description text that is drawn above the chart.
Marek Rosa
Added some documentation to QChart and QChartView
r274 */
Michal Klocek
Adds font handling for chart's titile...
r192 void QChart::setChartTitle(const QString& title)
Michal Klocek
Add background to chart...
r69 {
Michal Klocek
Refactors axis handling...
r223 createChartTitleItem();
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 m_titleItem->setText(title);
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 updateLayout();
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 }
/*!
Michal Klocek
Fixes for docs , adds xyseries docs
r481 Returns the chart title. The description text that is drawn above the chart.
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 */
QString QChart::chartTitle() const
{
if(m_titleItem)
return m_titleItem->text();
else
return QString();
Michal Klocek
Adds font handling for chart's titile...
r192 }
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Marek Rosa
Added some more documentation to QChart and QChartView
r277 Sets the \a font that is used for rendering the description text that is rendered above the chart.
Marek Rosa
Added some documentation to QChart and QChartView
r274 */
Michal Klocek
Adds font handling for chart's titile...
r192 void QChart::setChartTitleFont(const QFont& font)
{
Michal Klocek
Refactors axis handling...
r223 createChartTitleItem();
Michal Klocek
Adds title support
r87 m_titleItem->setFont(font);
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 updateLayout();
Michal Klocek
Add background to chart...
r69 }
Tero Ahola
Chart title font color
r495 /*!
Sets the \a brush used for rendering the title text.
*/
void QChart::setChartTitleBrush(const QBrush &brush)
{
createChartTitleItem();
m_titleItem->setBrush(brush);
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 updateLayout();
Tero Ahola
Chart title font color
r495 }
/*!
Returns the brush used for rendering the title text.
*/
QBrush QChart::chartTitleBrush()
{
createChartTitleItem();
return m_titleItem->brush();
}
Michal Klocek
Refactors axis handling...
r223 void QChart::createChartBackgroundItem()
{
if(!m_backgroundItem) {
m_backgroundItem = new QGraphicsRectItem(this);
Michal Klocek
Fix zorder of axis, and ticks
r272 m_backgroundItem->setPen(Qt::NoPen);
Michal Klocek
Adds ZOrder enum to presenter
r262 m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
Michal Klocek
Refactors axis handling...
r223 }
}
void QChart::createChartTitleItem()
{
Michal Klocek
Adds ZOrder enum to presenter
r262 if(!m_titleItem) {
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 m_titleItem = new QGraphicsSimpleTextItem(this);
Michal Klocek
Adds ZOrder enum to presenter
r262 m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
}
Michal Klocek
Refactors axis handling...
r223 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Returns the chart margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
\sa setMargin()
*/
Michal Klocek
Adds pimpl to qchart class
r28 int QChart::margin() const
{
Jani Honkonen
Pie chart refactoring
r142 return m_presenter->margin();
Michal Klocek
Adds pimpl to qchart class
r28 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Sets the chart \a margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
\sa margin()
*/
Michal Klocek
adds missing files form previous commit
r12 void QChart::setMargin(int margin)
{
Michal Klocek
Refactor themes...
r143 m_presenter->setMargin(margin);
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 updateLayout();
Michal Klocek
adds missing files form previous commit
r12 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 Sets the \a theme used by the chart for rendering the graphical representation of the data
Marek Rosa
Added some more documentation to QChart and QChartView
r277 \sa ChartTheme, chartTheme()
*/
Michal Klocek
Adds missing ids to theme classes
r153 void QChart::setChartTheme(QChart::ChartTheme theme)
Tero Ahola
Draft implementation for setting color themes for a chart
r64 {
Michal Klocek
Adds missing ids to theme classes
r153 m_presenter->setChartTheme(theme);
Tero Ahola
Draft implementation for setting color themes for a chart
r64 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Returns the theme enum used by the chart.
\sa ChartTheme, setChartTheme()
*/
Michal Klocek
Adds missing ids to theme classes
r153 QChart::ChartTheme QChart::chartTheme() const
Tero Ahola
Proof-of-concept for QML api...
r120 {
Michal Klocek
Adds missing ids to theme classes
r153 return m_presenter->chartTheme();
Tero Ahola
Proof-of-concept for QML api...
r120 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Zooms in the view by a factor of 2
*/
Michal Klocek
Refactors axis handling...
r223 void QChart::zoomIn()
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Refactor domain model...
r439 m_presenter->zoomIn();
Michal Klocek
Add zoom support...
r67 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Zooms in the view to a maximum level at which \a rect is still fully visible.
*/
Michal Klocek
Refactors axis handling...
r223 void QChart::zoomIn(const QRectF& rect)
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Refactor domain model...
r439
Michal Klocek
Refactors axis handling...
r223 if(!rect.isValid()) return;
Michal Klocek
Refactor domain model...
r439 m_presenter->zoomIn(rect);
Michal Klocek
Add zoom support...
r67 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Restores the view zoom level to the previous one.
*/
Michal Klocek
Add zoom support...
r67 void QChart::zoomOut()
{
Michal Klocek
Refactor domain model...
r439 m_presenter->zoomOut();
Michal Klocek
Add zoom support...
r67 }
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Resets to the default view.
*/
Tero Ahola
QChartWidget now zooms only x axis and zoom is reset with right click
r93 void QChart::zoomReset()
{
Michal Klocek
Refactor domain model...
r439 m_presenter->zoomReset();
Michal Klocek
Adds more axis handling...
r176 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Returns the pointer to the x axis object of the chart
*/
Michal Klocek
Refactors axis handling...
r223 QChartAxis* QChart::axisX() const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors axis handling...
r223 return m_dataset->axisX();
Michal Klocek
Adds more axis handling...
r176 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Returns the pointer to the y axis object of the chart
*/
Michal Klocek
Refactors axis handling...
r223 QChartAxis* QChart::axisY() const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors axis handling...
r223 return m_dataset->axisY();
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
sauimone
framework for legend
r524 /*!
Returns the legend object of the chart
*/
sauimone
background to legend, theme applies
r540 QLegend* QChart::legend()
sauimone
framework for legend
r524 {
return m_legend;
}
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Resizes and updates the chart area using the \a event data
*/
Michal Klocek
Adds layout support for charts....
r115 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
{
m_rect = QRectF(QPoint(0,0),event->newSize());
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 updateLayout();
Michal Klocek
Removes obsolate methods from qchart
r117 QGraphicsWidget::resizeEvent(event);
Michal Klocek
Adds layout support for charts....
r115 update();
}
Michal Klocek
Adds animation settings handling
r298 /*!
Tero Ahola
QDoc for animation options in QChart
r302 Sets animation \a options for the chart
Michal Klocek
Adds animation settings handling
r298 */
void QChart::setAnimationOptions(AnimationOptions options)
{
m_presenter->setAnimationOptions(options);
}
/*!
Returns animation options for the chart
*/
QChart::AnimationOptions QChart::animationOptions() const
{
return m_presenter->animationOptions();
}
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 void QChart::scrollLeft()
{
m_presenter->scroll(-m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
}
void QChart::scrollRight()
{
m_presenter->scroll(m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
}
void QChart::scrollUp()
{
m_presenter->scroll(0,m_presenter->geometry().width()/(axisY()->ticksCount()-1));
}
void QChart::scrollDown()
{
Michal Klocek
Adds scroll support...
r531 m_presenter->scroll(0,-m_presenter->geometry().width()/(axisY()->ticksCount()-1));
}
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 void QChart::updateLayout()
{
if(!m_rect.isValid()) return;
QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
// recalculate title position
if (m_titleItem) {
QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
}
//recalculate background gradient
if (m_backgroundItem) {
m_backgroundItem->setRect(rect);
}
sauimone
legend scaling with chart
r582
// recalculate legend position
// TODO: better layout
if (m_legend) {
QRectF boundingRect(m_rect.adjusted(margin(),
sauimone
fixed bug in legend name drawing
r585 rect.height() + margin() + margin()/2,
sauimone
legend scaling with chart
r582 -margin(),
sauimone
fixed bug in legend name drawing
r585 -margin()/2 + m_legend->minimumSize().height()));
sauimone
legend layouting change
r616 // m_legend->handleGeometryChanged(boundingRect);
QRectF br(0,0,margin(),m_rect.height());
m_legend->handleGeometryChanged(br);
m_legend->setPreferredLayout(QLegend::PreferredLayoutVertical);
sauimone
legend scaling with chart
r582 }
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 }
Tero Ahola
Draft implementation for setting color themes for a chart
r64 #include "moc_qchart.cpp"
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE