@@ -35,6 +35,7 BoxPlotChartItem::BoxPlotChartItem(QBoxPlotSeries *series, QGraphicsItem* item) | |||
|
35 | 35 | m_animation(0), |
|
36 | 36 | m_animate(0) |
|
37 | 37 | { |
|
38 | connect(series, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleBarsetRemove(QList<QBarSet*>))); | |
|
38 | 39 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleDataStructureChanged())); |
|
39 | 40 | connect(series->d_func(), SIGNAL(updatedLayout()), this, SLOT(handleLayoutChanged())); |
|
40 | 41 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleUpdatedBars())); |
@@ -76,7 +77,8 void BoxPlotChartItem::setAnimation(BoxPlotAnimation *animation) | |||
|
76 | 77 | |
|
77 | 78 | void BoxPlotChartItem::handleDataStructureChanged() |
|
78 | 79 | { |
|
79 |
|
|
|
80 | qDebug() << "BoxPlotChartItem::handleDataStructureChanged()"; | |
|
81 | ||
|
80 | 82 | int setCount = m_series->count(); |
|
81 | 83 | |
|
82 | 84 | for (int s = 0; s < setCount; s++) { |
@@ -105,7 +107,7 void BoxPlotChartItem::handleDataStructureChanged() | |||
|
105 | 107 | |
|
106 | 108 | void BoxPlotChartItem::handleUpdatedBars() |
|
107 | 109 | { |
|
108 |
|
|
|
110 | qDebug() << "BoxPlotChartItem::handleUpdatedBars()"; | |
|
109 | 111 | |
|
110 | 112 | foreach (BoxWhiskers *item, m_boxTable.values()) { |
|
111 | 113 | item->setBrush(m_series->brush()); |
@@ -113,6 +115,19 void BoxPlotChartItem::handleUpdatedBars() | |||
|
113 | 115 | } |
|
114 | 116 | } |
|
115 | 117 | |
|
118 | void BoxPlotChartItem::handleBarsetRemove(QList<QBarSet*> barSets) | |
|
119 | { | |
|
120 | //qDebug() << "BoxPlotChartItem::handleBarsetRemove"; | |
|
121 | ||
|
122 | foreach (QBarSet *set, barSets) { | |
|
123 | BoxWhiskers *boxItem = m_boxTable.value(set); | |
|
124 | m_boxTable.remove(set); | |
|
125 | delete boxItem; | |
|
126 | } | |
|
127 | ||
|
128 | // We trust that series emits the restructuredBars, which handles restructuring | |
|
129 | } | |
|
130 | ||
|
116 | 131 | void BoxPlotChartItem::handleDomainUpdated() |
|
117 | 132 | { |
|
118 | 133 | //qDebug() << "BoxPlotChartItem::handleDomainUpdated() domain()->size() = " << domain()->size(); |
@@ -136,6 +151,8 void BoxPlotChartItem::handleDomainUpdated() | |||
|
136 | 151 | |
|
137 | 152 | void BoxPlotChartItem::handleLayoutChanged() |
|
138 | 153 | { |
|
154 | qDebug() << "BoxPlotChartItem::handleLayoutChanged"; | |
|
155 | ||
|
139 | 156 | foreach (BoxWhiskers *item, m_boxTable.values()) { |
|
140 | 157 | if (m_animation) |
|
141 | 158 | m_animation->setAnimationStart(item); |
@@ -35,6 +35,7 | |||
|
35 | 35 | #include "qboxplotseries.h" |
|
36 | 36 | #include "chartitem_p.h" |
|
37 | 37 | #include "boxplotanimation_p.h" |
|
38 | #include "qbarset.h" | |
|
38 | 39 | #include <QGraphicsItem> |
|
39 | 40 | |
|
40 | 41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -58,6 +59,7 public Q_SLOTS: | |||
|
58 | 59 | void handleDomainUpdated(); |
|
59 | 60 | void handleLayoutChanged(); |
|
60 | 61 | void handleUpdatedBars(); |
|
62 | void handleBarsetRemove(QList<QBarSet*> barSets); | |
|
61 | 63 | |
|
62 | 64 | private: |
|
63 | 65 | virtual QVector<QRectF> calculateLayout(); |
@@ -29,6 +29,7 BoxWhiskers::BoxWhiskers(AbstractDomain *domain, QGraphicsObject *parent) : | |||
|
29 | 29 | QGraphicsObject(parent), |
|
30 | 30 | m_domain(domain) |
|
31 | 31 | { |
|
32 | //qDebug() << "BoxWhiskers::BoxWhiskers()"; | |
|
32 | 33 | } |
|
33 | 34 | |
|
34 | 35 | BoxWhiskers::~BoxWhiskers() |
@@ -71,12 +71,16 MainWidget::MainWidget(QWidget *parent) : | |||
|
71 | 71 | connect(removeSeriesButton, SIGNAL(clicked()), this, SLOT(removeSeries())); |
|
72 | 72 | grid->addWidget(removeSeriesButton, rowPos++, 1); |
|
73 | 73 | |
|
74 | ||
|
75 | 74 | // Create add a single box button |
|
76 | 75 | QPushButton *addBoxButton = new QPushButton("Add a box"); |
|
77 | 76 | connect(addBoxButton, SIGNAL(clicked()), this, SLOT(addBox())); |
|
78 | 77 | grid->addWidget(addBoxButton, rowPos++, 1); |
|
79 | 78 | |
|
79 | // Create add a single box button | |
|
80 | QPushButton *removeBoxButton = new QPushButton("Remove a box"); | |
|
81 | connect(removeBoxButton, SIGNAL(clicked()), this, SLOT(removeBox())); | |
|
82 | grid->addWidget(removeBoxButton, rowPos++, 1); | |
|
83 | ||
|
80 | 84 | initThemeCombo(grid); |
|
81 | 85 | initCheckboxes(grid); |
|
82 | 86 | |
@@ -208,6 +212,8 void MainWidget::removeSeries() | |||
|
208 | 212 | nSeries--; |
|
209 | 213 | m_chart->removeSeries(m_series[nSeries]); |
|
210 | 214 | delete m_series[nSeries]; |
|
215 | } else { | |
|
216 | qDebug() << "Create a series first"; | |
|
211 | 217 | } |
|
212 | 218 | } |
|
213 | 219 | |
@@ -215,6 +221,7 void MainWidget::addBox() | |||
|
215 | 221 | { |
|
216 | 222 | qDebug() << "BoxPlotTester::MainWidget::addBox()"; |
|
217 | 223 | |
|
224 | if (nSeries > 0) { | |
|
218 | 225 | QBarSet *newSet = new QBarSet("New"); |
|
219 | 226 | *newSet << 5 << 6 << 6.8 << 7 << 8; |
|
220 | 227 | |
@@ -224,6 +231,19 void MainWidget::addBox() | |||
|
224 | 231 | |
|
225 | 232 | nNewBoxes++; |
|
226 | 233 | } |
|
234 | } | |
|
235 | ||
|
236 | void MainWidget::removeBox() | |
|
237 | { | |
|
238 | qDebug() << "MainWidget::removeBox"; | |
|
239 | ||
|
240 | if (nSeries > 0) { | |
|
241 | QList<QBarSet *> sets = m_series[0]->barSets(); | |
|
242 | m_series[0]->remove(sets.at(m_series[0]->count() - 3)); | |
|
243 | } else { | |
|
244 | qDebug() << "Create a series first"; | |
|
245 | } | |
|
246 | } | |
|
227 | 247 | |
|
228 | 248 | void MainWidget::animationToggled(bool enabled) |
|
229 | 249 | { |
General Comments 0
You need to be logged in to leave comments.
Login now