##// END OF EJS Templates
Reformats about page
Reformats about page

File last commit:

r288:5f68000bea7a
r336:dd25dfe23960
Show More
barpresenter.cpp
97 lines | 3.0 KiB | text/x-c | CppLexer
sauimone
Common naming convention for barcharts
r216 #include "barpresenter.h"
sauimone
renamed bar.h to bar_p.h
r118 #include "bar_p.h"
sauimone
added labels to barcharts
r114 #include "barlabel_p.h"
sauimone
Floating values to bar charts
r263 #include "barvalue_p.h"
sauimone
Added pen & brush to QBarSet
r214 #include "qbarset.h"
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
moved tooltip to presenter
r288 BarPresenter::BarPresenter(QBarChartSeries *series, QGraphicsItem *parent) :
BarPresenterBase(series, parent)
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 {
sauimone
Floating values to bar charts
r263 mBarDefaultWidth = 15;
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 }
sauimone
Common naming convention for barcharts
r216 void BarPresenter::layoutChanged()
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 {
// Scale bars to new layout
// Layout for bars:
sauimone
moved tooltip to presenter
r288 if (mSeries->countSets() <= 0) {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 qDebug() << "No sets in model!";
sauimone
model prototyping for bar chart
r159 return;
}
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56
sauimone
bug fix in bar charts. Crashed, if layout was set before data. Also integrated to test app.
r165 if (childItems().count() == 0) {
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 qDebug() << "WARNING: BarPresenter::layoutChanged called before graphics items are created!";
sauimone
bug fix in bar charts. Crashed, if layout was set before data. Also integrated to test app.
r165 return;
}
sauimone
percent bar chart
r101 // TODO: better way to auto-layout?
sauimone
bar chart layout fixing
r99 // Use reals for accurancy (we might get some compiler warnings... :)
sauimone
moved tooltip to presenter
r288 int categoryCount = mSeries->countCategories();
int setCount = mSeries->countSets();
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56
sauimone
bar chart layout fixing
r99 qreal tW = mWidth;
qreal tH = mHeight;
sauimone
moved tooltip to presenter
r288 qreal tM = mSeries->max();
sauimone
bar chart layout fixing
r99 qreal scale = (tH/tM);
sauimone
Floating values to bar charts
r263 qreal tC = categoryCount+1;
sauimone
brush support for bargroups
r183 qreal xStepPerSet = (tW/tC);
sauimone
bar chart layout fixing
r99
sauimone
correct drawing for barchart
r82 // Scaling.
sauimone
Improved bar chart series
r71 int itemIndex(0);
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 int labelIndex(0);
sauimone
added labels to barcharts
r114
sauimone
Floating values to bar charts
r263 for (int category=0; category < categoryCount; category++) {
qreal xPos = xStepPerSet * category + ((tW + mBarDefaultWidth*setCount)/(categoryCount*2));
sauimone
theme interface to barcharts. some minor fixes
r113 qreal yPos = mHeight;
sauimone
brush support for bargroups
r183 for (int set = 0; set < setCount; set++) {
sauimone
moved tooltip to presenter
r288 qreal barHeight = mSeries->valueAt(set,category) * scale;
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 Bar* bar = mBars.at(itemIndex);
sauimone
bar chart layout fixing
r99
// TODO: width settable per bar?
bar->resize(mBarDefaultWidth, barHeight);
sauimone
moved tooltip to presenter
r288 bar->setBrush(mSeries->setAt(set)->brush());
bar->setPos(xPos, yPos-barHeight);
sauimone
bar chart layout fixing
r99 itemIndex++;
xPos += mBarDefaultWidth;
}
sauimone
added labels to barcharts
r114
// TODO: Layout for labels, remove magic number
sauimone
Floating values to bar charts
r263 xPos = xStepPerSet * category + ((tW + mBarDefaultWidth*setCount)/(categoryCount*2));
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 BarLabel* label = mLabels.at(labelIndex);
sauimone
added labels to barcharts
r114 label->setPos(xPos, mHeight + 20);
labelIndex++;
sauimone
bar chart layout fixing
r99 }
sauimone
Floating values to bar charts
r263 // Position floating values
itemIndex = 0;
sauimone
moved tooltip to presenter
r288 for (int category=0; category < mSeries->countCategories(); category++) {
sauimone
Floating values to bar charts
r263 qreal xPos = xStepPerSet * category + ((tW + mBarDefaultWidth*setCount)/(categoryCount*2));
qreal yPos = mHeight;
sauimone
moved tooltip to presenter
r288 for (int set=0; set < mSeries->countSets(); set++) {
qreal barHeight = mSeries->valueAt(set,category) * scale;
sauimone
Floating values to bar charts
r263 BarValue* value = mFloatingValues.at(itemIndex);
// TODO: remove hard coding, apply layout
value->resize(100,50);
sauimone
updated barchart examples. minor fixes
r276 value->setPos(xPos, yPos-barHeight/2);
sauimone
Floating values to bar charts
r263 value->setPen(QPen(QColor(255,255,255,255)));
sauimone
moved tooltip to presenter
r288 if (mSeries->valueAt(set,category) != 0) {
value->setValueString(QString::number(mSeries->valueAt(set,category)));
sauimone
updated barchart examples. minor fixes
r276 } else {
value->setValueString(QString(""));
}
sauimone
Floating values to bar charts
r263
itemIndex++;
xPos += mBarDefaultWidth;
}
}
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 mLayoutDirty = true;
}
sauimone
moved tooltip to presenter
r288 #include "moc_barpresenter.cpp"
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 QTCOMMERCIALCHART_END_NAMESPACE