void ParallelMachine::drawLoad(QGraphicsScene &scene) { std::vector<LoadType> load; std::vector<size_t> n_cells, n_particles; for (NodeThreadArray::iterator it = threads.begin(); it != threads.end(); it++) { load.push_back(it->getCurrentLoad()); n_cells.push_back(it->getCurrentNumOfCells()); n_particles.push_back(it->getCurrentNumOfParticles()); } QFontMetrics metrics(scene.font()); const size_t elem_height = (metrics.height() > 20) ? metrics.height() : 20; const LoadType total_load = std::accumulate(load.begin(), load.end(), 0.0); size_t pos_x = 0, pos_y = 0; for (size_t i = 0; i < threads.size(); i++) { pos_x = drawText(scene, QString("%1").arg(i, -3), 0, pos_y).right(); pos_x = drawRect(scene, pos_x, pos_y, len(load[i], total_load, 100), elem_height, Qt::red).right(); pos_x = drawRect(scene, pos_x, pos_y, len(n_cells[i], total_num_of_cells, 100), elem_height, Qt::green).right(); pos_x = drawRect(scene, pos_x, pos_y, len(n_particles[i], total_num_of_particles, 100), elem_height, Qt::blue).right(); pos_x = drawText(scene, QString("L: %1, C: %2, P: %3"). arg(load[i]).arg(n_cells[i]).arg(n_particles[i]), pos_x, pos_y).right(); pos_y += elem_height + 2; } drawText(scene, QString("Max diff: L: %1, C: %2, P: %3"). arg(diff(load)).arg(diff(n_cells)).arg(diff(n_particles)), 0, pos_y).right(); }
QFont font() const { return _scene->font(); }