From 23a271e217e1e9309c8efa08c0a635fc0498f7af 2012-02-09 12:12:44 From: Michal Klocek Date: 2012-02-09 12:12:44 Subject: [PATCH] Remove PlotDomain , use Domain insted * clean old setSize SetPlotDomain iterface * remove all PlotDomain references --- diff --git a/src/barchart/bar.cpp b/src/barchart/bar.cpp index 107806d..8e2d066 100644 --- a/src/barchart/bar.cpp +++ b/src/barchart/bar.cpp @@ -15,10 +15,6 @@ void Bar::setSize(const QSizeF& size) mHeight = size.height(); } -void Bar::setPlotDomain(const PlotDomain& data) -{ - mPlotDomain = data; -} void Bar::resize( qreal w, qreal h ) { diff --git a/src/barchart/bar_p.h b/src/barchart/bar_p.h index 323cb4e..1a40209 100644 --- a/src/barchart/bar_p.h +++ b/src/barchart/bar_p.h @@ -15,7 +15,6 @@ public: public: // from ChartItem void setSize(const QSizeF &size); - void setPlotDomain(const PlotDomain& data); // Layout Stuff void resize( qreal w, qreal h ); // Size of bar. @@ -36,7 +35,6 @@ private: qreal mYpos; QColor mColor; - PlotDomain mPlotDomain; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/barlabel.cpp b/src/barchart/barlabel.cpp index e94ef47..aa63668 100644 --- a/src/barchart/barlabel.cpp +++ b/src/barchart/barlabel.cpp @@ -23,11 +23,6 @@ void BarLabel::setSize(const QSizeF &size) mSize = size; } -void BarLabel::setPlotDomain(const PlotDomain& data) -{ - mDomain = data; -} - void BarLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->drawText(boundingRect(),mLabel); diff --git a/src/barchart/barlabel_p.h b/src/barchart/barlabel_p.h index 2c4cdcc..c038126 100644 --- a/src/barchart/barlabel_p.h +++ b/src/barchart/barlabel_p.h @@ -15,7 +15,6 @@ public: // From ChartItem void setSize(const QSizeF &size); - void setPlotDomain(const PlotDomain& data); // From QGraphicsItem void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -23,7 +22,6 @@ public: private: - PlotDomain mDomain; QSizeF mSize; QString mLabel; qreal mXpos; diff --git a/src/barchart/separator.cpp b/src/barchart/separator.cpp index 12a1885..0f2135e 100644 --- a/src/barchart/separator.cpp +++ b/src/barchart/separator.cpp @@ -26,11 +26,6 @@ void Separator::setSize(const QSizeF &size) mHeight = size.height(); } -void Separator::setPlotDomain(const PlotDomain& data) -{ - -} - void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { qDebug() << "separator::paint" << boundingRect(); diff --git a/src/barchart/separator_p.h b/src/barchart/separator_p.h index 2a59775..cee7485 100644 --- a/src/barchart/separator_p.h +++ b/src/barchart/separator_p.h @@ -15,7 +15,6 @@ public: // From ChartItem void setSize(const QSizeF &size); - void setPlotDomain(const PlotDomain& data); // From QGraphicsItem void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); diff --git a/src/chartitem_p.h b/src/chartitem_p.h index 547e051..0d01c8d 100644 --- a/src/chartitem_p.h +++ b/src/chartitem_p.h @@ -1,7 +1,6 @@ #ifndef CHARTITEM_H_ #define CHARTITEM_H_ -#include "plotdomain_p.h" #include "domain_p.h" #include diff --git a/src/piechart/piepresenter.cpp b/src/piechart/piepresenter.cpp index 3472bc0..b8db4d6 100644 --- a/src/piechart/piepresenter.cpp +++ b/src/piechart/piepresenter.cpp @@ -47,19 +47,6 @@ void PiePresenter::seriesChanged() resize(); } -void PiePresenter::setSize(const QSizeF &size) -{ - // TODO: allow user setting the size? - // TODO: allow user defining the margins? - m_rect.setSize(size); - resize(); -} - -void PiePresenter::setPlotDomain(const PlotDomain& plotDomain) -{ - // TODO -} - void PiePresenter::resize() { m_pieRect = m_rect; @@ -114,7 +101,10 @@ void PiePresenter::handleDomainChanged(const Domain& domain) void PiePresenter::handleGeometryChanged(const QRectF& rect) { - setSize(rect.size()); + // TODO: allow user setting the size? + // TODO: allow user defining the margins? + m_rect.setSize(rect.size()); + resize(); } #include "moc_piepresenter.cpp" diff --git a/src/piechart/piepresenter.h b/src/piechart/piepresenter.h index 3e88645..50bca99 100644 --- a/src/piechart/piepresenter.h +++ b/src/piechart/piepresenter.h @@ -18,8 +18,6 @@ public: ~PiePresenter(); public: // from ChartItem - void setSize(const QSizeF &size); - void setPlotDomain(const PlotDomain& data); QRectF boundingRect() const { return m_rect; } void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {} diff --git a/src/plotdomain.cpp b/src/plotdomain.cpp deleted file mode 100644 index b96574e..0000000 --- a/src/plotdomain.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "plotdomain_p.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -PlotDomain::PlotDomain(): -m_minX(0), -m_maxX(0), -m_minY(0), -m_maxY(0) -{ - -} - -PlotDomain::~PlotDomain() -{ - // TODO Auto-generated destructor stub -} - -qreal PlotDomain::spanX() const -{ - Q_ASSERT(m_maxX >= m_minX); - return m_maxX - m_minX; -} - -qreal PlotDomain::spanY() const -{ - Q_ASSERT(m_maxY >= m_minY); - return m_maxY - m_minY; -} - -PlotDomain PlotDomain::subDomain(const QRectF& rect, qreal maxWidth,qreal maxHeight) const -{ - PlotDomain domain; - - qreal dx = spanX() / maxWidth; - qreal dy = spanY() / maxHeight; - - domain.m_minX = m_minX + dx * rect.left(); - domain.m_maxX = m_minX + dx * rect.right(); - domain.m_minY = m_maxY - dy * rect.bottom(); - domain.m_maxY = m_maxY - dy * rect.top(); - - return domain; -} -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/plotdomain_p.h b/src/plotdomain_p.h deleted file mode 100644 index e813dd1..0000000 --- a/src/plotdomain_p.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PLOTDOMAIN_H_ -#define PLOTDOMAIN_H_ -#include "qchartglobal.h" -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class PlotDomain { -public: - PlotDomain(); - virtual ~PlotDomain(); - - qreal spanX() const; - qreal spanY() const; - - PlotDomain subDomain(const QRectF& rect, qreal maxWidth, qreal maxHeight) const; - - -public: - qreal m_minX; - qreal m_maxX; - qreal m_minY; - qreal m_maxY; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif /* PLOTTER_H_ */ diff --git a/src/qchart.cpp b/src/qchart.cpp index 7fdcb8a..30d5cb2 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -1,13 +1,8 @@ #include "qchart.h" -#include "qchartseries.h" #include "qscatterseries.h" #include "qscatterseries_p.h" #include "qpieseries.h" #include "qchartaxis.h" -#include "charttheme_p.h" -#include "chartitem_p.h" -#include "plotdomain_p.h" -#include "axisitem_p.h" #include "chartpresenter_p.h" #include "chartdataset_p.h" diff --git a/src/qscatterseries.cpp b/src/qscatterseries.cpp index edb0782..b01fa31 100644 --- a/src/qscatterseries.cpp +++ b/src/qscatterseries.cpp @@ -49,9 +49,9 @@ void QScatterSeriesPrivate::themeChanged(ChartTheme *theme) //m_theme = theme->themeForSeries(); } -void QScatterSeriesPrivate::setPlotDomain(const PlotDomain& plotDomain) +void QScatterSeriesPrivate::setPlotDomain(const Domain& plotDomain) { - m_visibleChartArea = plotDomain; + //m_visibleChartArea = plotDomain; changeGeometry(); } diff --git a/src/qscatterseries_p.h b/src/qscatterseries_p.h index 5af4ba4..896b8be 100644 --- a/src/qscatterseries_p.h +++ b/src/qscatterseries_p.h @@ -4,7 +4,7 @@ #include "qchartseries.h" #include "charttheme_p.h" #include "chartitem_p.h" -#include "plotdomain_p.h" +#include "domain_p.h" #include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -19,7 +19,7 @@ public: public: // from ChartObjectInterface void setSize(const QSizeF &size); - void setPlotDomain(const PlotDomain& data); + void setPlotDomain(const Domain& data); public: // from ChartThemeObserver void themeChanged(ChartTheme *theme); @@ -39,7 +39,7 @@ public: QList m_sceney; QColor m_markerColor; //SeriesTheme m_theme; - PlotDomain m_visibleChartArea; + Domain m_visibleChartArea; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/src.pro b/src/src.pro index 02b7382..af887e4 100644 --- a/src/src.pro +++ b/src/src.pro @@ -20,7 +20,6 @@ SOURCES += barchart/barchartseries.cpp \ barchart/separator.cpp \ barchart/bargroupbase.cpp \ barchart/barchartseriesbase.cpp \ - plotdomain.cpp \ qscatterseries.cpp \ qchart.cpp \ axisitem.cpp \ @@ -36,7 +35,6 @@ PRIVATE_HEADERS += linechart/linechartitem_p.h \ barchart/barlabel_p.h \ barchart/bar_p.h \ barchart/separator_p.h \ - plotdomain_p.h \ qscatterseries_p.h \ axisitem_p.h \ chartitem_p.h \