##// END OF EJS Templates
Add padding for axis title...
Add padding for axis title Added three pixel padding on either side of the axis title to avoid overlaps with axis labels and neighboring axis lines. Task-number: QTRD-1903 Reviewed-by: Mika Salmela

File last commit:

r2413:f80448ee2136
r2413:f80448ee2136
Show More
chartaxis_p.h
201 lines | 6.2 KiB | text/x-c | CLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
unknown
Added missing warning about private implementation
r1366 // W A R N I N G
// -------------
//
// This file is not part of the QtCommercial Chart API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
Michal Klocek
Refactors axis animation, line animations
r1241 #ifndef CHARTAXIS_H
#define CHARTAXIS_H
Michal Klocek
Add zoom support...
r67
Michal Klocek
Refactor qledgend handling...
r855 #include "qchartglobal.h"
Michal Klocek
Refactors Chart to ChartElement
r1736 #include "chartelement_p.h"
Michal Klocek
Refactors axis animation, line animations
r1241 #include "axisanimation_p.h"
Michal Klocek
Add zoom support...
r67 #include <QGraphicsItem>
Michal Klocek
Refactors layout...
r1965 #include <QGraphicsLayoutItem>
Michal Klocek
Refactors layout managment...
r1534 #include <QFont>
Michal Klocek
Add zoom support...
r67
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactors QAxis to QAbstractAxis...
r1541 class QAbstractAxis;
Michal Klocek
Animation refactor...
r530 class ChartPresenter;
Michal Klocek
Adds refactored axis to presenter
r140
Michal Klocek
Refactors layout...
r1965 class ChartAxis : public ChartElement, public QGraphicsLayoutItem
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Adds refactored axis to presenter
r140 Q_OBJECT
Michal Klocek
Refactors layout...
r1965 Q_INTERFACES(QGraphicsLayoutItem)
Michal Klocek
Add zoom support...
r67 public:
Michal Klocek
Refactors internals...
r2273 ChartAxis(QAbstractAxis *axis, QGraphicsItem* item = 0, bool intervalAxis = false);
Michal Klocek
Changes QChartAxis -> QAxis
r1006 ~ChartAxis();
Michal Klocek
Add zoom support...
r67
Michal Klocek
Refactors internals...
r2273 QAbstractAxis* axis() const { return m_axis; }
Michal Klocek
Refactors ChartAxis...
r2138
Michal Klocek
Refactors layout:...
r2105 void setLabelPadding(int padding);
int labelPadding() const { return m_labelPadding;};
Michal Klocek
Adds more axis handling...
r176
Miikka Heikkinen
Add padding for axis title...
r2413 void setTitlePadding(int padding);
int titlePadding() const { return m_titlePadding;};
Michal Klocek
Makes theming axis title aware
r2153 QFont titleFont() const;
Michal Klocek
Refactors internals...
r2273 QString titleText() const;
Michal Klocek
Refactors layout...
r1965
Michal Klocek
Refactors axis animation, line animations
r1241 void setLayout(QVector<qreal> &layout);
QVector<qreal> layout() const { return m_layoutVector; }
Jani Honkonen
more coding style fixes for src-folder...
r2104 void setAnimation(AxisAnimation *animation);
ChartAnimation *animation() const { return m_animation; };
Michal Klocek
Refactors axis animation, line animations
r1241
Michal Klocek
Refactors layout...
r1965 Qt::Orientation orientation() const;
Michal Klocek
Refactors layout:...
r2105 Qt::Alignment alignment() const;
Michal Klocek
Refactors layout managment...
r1534
Michal Klocek
Refactors layout:...
r2105 void setGeometry(const QRectF &axis, const QRectF &grid);
QRectF axisGeometry() const { return m_axisRect; }
QRectF gridGeometry() const { return m_gridRect; }
Marek Rosa
Multiaxis support...
r2093
Jani Honkonen
src folder: another massive victory for coding style police
r2131 void setLabels(const QStringList &labels);
Michal Klocek
Refactors axis updateGeometry handling...
r2111 QStringList labels() const { return m_labelsList; }
Michal Klocek
Remove setter for labelinBeetwen flag from axis
r2118 //this flag indicates that axis is used to show intervals it means labels are in between ticks
bool intervalAxis() const { return m_intervalAxis; }
Michal Klocek
Refactors axis updateGeometry handling...
r2111
Jani Honkonen
more coding style fixes for src-folder...
r2104 virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
Michal Klocek
Refactors layout...
r1965
Michal Klocek
Refactors internals...
r2273
QRectF boundingRect() const{
return QRectF();
}
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)
{
}
//helpers
static QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format);
Marek Rosa
QLogValueAxis added. Log domain missing
r2274 static QStringList createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString& format);
Michal Klocek
Refactors internals...
r2273 static QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format);
Michal Klocek
Refactors axis animation, line animations
r1241 protected:
Jani Honkonen
src folder: another massive victory for coding style police
r2131 void setGeometry(const QRectF &size) { Q_UNUSED(size);};
Michal Klocek
Refactors axis animation, line animations
r1241 virtual void updateGeometry() = 0;
virtual QVector<qreal> calculateLayout() const = 0;
Michal Klocek
Refactors layout...
r1965
Michal Klocek
Refactors axis updateGeometry handling...
r2111 QList<QGraphicsItem *> lineItems() { return m_grid->childItems(); };
QList<QGraphicsItem *> labelItems() { return m_labels->childItems();};
QList<QGraphicsItem *> shadeItems() { return m_shades->childItems();};
QList<QGraphicsItem *> arrowItems() { return m_arrow->childItems();};
Michal Klocek
Adds ScopedPointer for axis title element
r2141 QGraphicsSimpleTextItem* titleItem() const { return m_title.data();}
Michal Klocek
Refactors axis updateGeometry handling...
r2111
Michal Klocek
Refactors internals...
r2273 QFont font() const;
qreal min() const;
qreal max() const;
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 QRect labelBoundingRect(const QFontMetrics &fn, const QString &label) const;
Michal Klocek
Fix grid animation to do not go out of bound
r504
Michal Klocek
Refactors internals...
r2273 //handlers
sauimone
Q_SIGNALS and Q_SLOTS
r775 public Q_SLOTS:
Michal Klocek
Refactors internals...
r2273 void handleVisibleChanged(bool visible);
void handleArrowVisibleChanged(bool visible);
void handleGridVisibleChanged(bool visible);
void handleLabelsVisibleChanged(bool visible);
void handleShadesVisibleChanged(bool visible);
void handleLabelsAngleChanged(int angle);
void handleShadesBrushChanged(const QBrush &brush);
void handleShadesPenChanged(const QPen &pen);
void handleArrowPenChanged(const QPen &pen);
void handleGridPenChanged(const QPen &pen);
void handleLabelsPenChanged(const QPen &pen);
void handleLabelsBrushChanged(const QBrush &brush);
void handleLabelsFontChanged(const QFont &font);
void handleTitlePenChanged(const QPen &pen);
void handleTitleBrushChanged(const QBrush &brush);
void handleTitleFontChanged(const QFont &font);
void handleTitleTextChanged(const QString &title);
Michal Klocek
Bugfix: axis visibily issues...
r2297 void handleTitleVisibleChanged(bool visible);
Michal Klocek
Refactors internals...
r2273 void handleRangeChanged(qreal min , qreal max);
Q_SIGNALS:
void clicked();
Michal Klocek
Refactors layout...
r1965
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 private:
Michal Klocek
Refacotr axisitem to handle ticks changes
r452 inline bool isEmpty();
Michal Klocek
Refactors axis handling...
r223 void createItems(int count);
Michal Klocek
Axis refactoring to support better barcharts
r502 void deleteItems(int count);
sauimone
more minor code review fixes
r745 void updateLayout(QVector<qreal> &layout);
Michal Klocek
Refactors chartitem...
r677 void axisSelected();
Michal Klocek
Refactors internals...
r2273 void connectSlots();
Michal Klocek
Adds draft of axis bar label support
r497
Michal Klocek
Refactors axis updateGeometry handling...
r2111 private:
Michal Klocek
Refactors internals...
r2273 QAbstractAxis *m_axis;
Michal Klocek
Adds more axis handling...
r176 int m_labelsAngle;
Michal Klocek
Refactors layout:...
r2105 QRectF m_axisRect;
QRectF m_gridRect;
Michal Klocek
Adds axis scoped pointers (to be checked on windows)
r788 QScopedPointer<QGraphicsItemGroup> m_grid;
Michal Klocek
Refactors internals...
r2273 QScopedPointer<QGraphicsItemGroup> m_arrow;
Michal Klocek
Adds axis scoped pointers (to be checked on windows)
r788 QScopedPointer<QGraphicsItemGroup> m_shades;
QScopedPointer<QGraphicsItemGroup> m_labels;
Michal Klocek
Adds ScopedPointer for axis title element
r2141 QScopedPointer<QGraphicsSimpleTextItem> m_title;
Michal Klocek
Refactors axis layout managment...
r291 QVector<qreal> m_layoutVector;
Michal Klocek
Refactors axis animation, line animations
r1241 AxisAnimation *m_animation;
Michal Klocek
Refactors layout:...
r2105 int m_labelPadding;
Michal Klocek
Refactors axis updateGeometry handling...
r2111 QStringList m_labelsList;
Michal Klocek
Remove setter for labelinBeetwen flag from axis
r2118 bool m_intervalAxis;
Miikka Heikkinen
Add padding for axis title...
r2413 int m_titlePadding;
Michal Klocek
Adds refactored axis to presenter
r140
Jani Honkonen
src folder: another massive victory for coding style police
r2131 friend class AxisAnimation;
Michal Klocek
Refactors internals...
r2273 friend class ArrowItem;
Michal Klocek
Refactors chartitem...
r677
};
Michal Klocek
Refactors internals...
r2273 class ArrowItem: public QGraphicsLineItem
Michal Klocek
Refactors chartitem...
r677 {
Michal Klocek
Normalizes signal slots connections
r967 public:
Michal Klocek
Refactors internals...
r2273 explicit ArrowItem(ChartAxis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {}
Michal Klocek
Refactors chartitem...
r677
protected:
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 void mousePressEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED(event)
m_axis->axisSelected();
}
QRectF boundingRect() const {
return shape().boundingRect();
}
QPainterPath shape() const {
QPainterPath path = QGraphicsLineItem::shape();
QRectF rect = path.boundingRect();
Michal Klocek
Refactors axis updateGeometry handling...
r2111 path.addRect(rect.adjusted(0, 0, m_axis->orientation() != Qt::Horizontal ? 8 : 0, m_axis->orientation() != Qt::Vertical ? 8 : 0));
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 return path;
}
Michal Klocek
Refactors barchart axis hadnling...
r679
Michal Klocek
Refactors chartitem...
r677 private:
Jani Honkonen
more coding style fixes for src-folder...
r2104 ChartAxis *m_axis;
Michal Klocek
Add zoom support...
r67 };
QTCOMMERCIALCHART_END_NAMESPACE
Jani Honkonen
Fix Krazy issues
r1935 #endif /* CHARTAXI_H */