13 #include <QVBoxLayout>
14 #include <QGraphicsScene>
15 #include <QGraphicsView>
17 #include <QGraphicsRectItem>
28 AutoFitView(QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent) { }
32 QGraphicsView::resizeEvent(
event);
33 fitInView(scene()->sceneRect());
39 setWindowTitle(tr(
"Monster resistances"));
40 auto layout =
new QVBoxLayout(
this);
42 myScene =
new QGraphicsScene(
this);
44 layout->addWidget(
new QLabel(tr(
"Monster resistances (by steps of 10):")));
58 std::map<int, std::map<int, int>> values;
59 int maxCount = 0, minResist = INT_MAX, maxResist = INT_MIN;
66 auto mr =
arch->clone.resist;
68 int val = mr[
r.first] / 10;
69 minResist = qMin(minResist, val);
70 maxResist = qMax(maxResist, val);
71 values[
r.first][val]++;
72 maxCount = qMax(values[
r.first][val], maxCount);
82 for (
int i = minResist; i <= maxResist; i++) {
83 if (values[
r.first][i] == 0) {
86 auto item =
myScene->addRect(qreal((i - minResist) *
SCALE *
myResistances.size() + shift), qreal(maxCount - values[
r.first][i]), qreal(
SCALE - 1), qreal(values[
r.first][i]), p, br);
87 item->setToolTip(tr(
"%1% %2: %3 monsters").arg(i * 10).arg(
resist_plus[
r.first]).arg(values[
r.first][i]));