2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-11-23 08:31:03 +00:00
|
|
|
#include "chip.h"
|
2011-04-27 10:05:43 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "view.h"
|
|
|
|
|
2012-11-23 08:31:03 +00:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QSplitter>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
2019-09-01 15:12:01 +00:00
|
|
|
: QWidget(parent), scene(new QGraphicsScene(this))
|
|
|
|
, h1Splitter(new QSplitter(this)), h2Splitter(new QSplitter(this))
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
populateScene();
|
|
|
|
|
|
|
|
QSplitter *vSplitter = new QSplitter;
|
|
|
|
vSplitter->setOrientation(Qt::Vertical);
|
|
|
|
vSplitter->addWidget(h1Splitter);
|
|
|
|
vSplitter->addWidget(h2Splitter);
|
|
|
|
|
|
|
|
View *view = new View("Top left view");
|
|
|
|
view->view()->setScene(scene);
|
|
|
|
h1Splitter->addWidget(view);
|
|
|
|
|
|
|
|
view = new View("Top right view");
|
|
|
|
view->view()->setScene(scene);
|
|
|
|
h1Splitter->addWidget(view);
|
|
|
|
|
|
|
|
view = new View("Bottom left view");
|
|
|
|
view->view()->setScene(scene);
|
|
|
|
h2Splitter->addWidget(view);
|
|
|
|
|
|
|
|
view = new View("Bottom right view");
|
|
|
|
view->view()->setScene(scene);
|
|
|
|
h2Splitter->addWidget(view);
|
|
|
|
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
|
|
layout->addWidget(vSplitter);
|
|
|
|
setLayout(layout);
|
|
|
|
|
2011-07-04 08:30:18 +00:00
|
|
|
setWindowTitle(tr("Chip Example"));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::populateScene()
|
|
|
|
{
|
|
|
|
QImage image(":/qt4logo.png");
|
|
|
|
|
|
|
|
// Populate scene
|
|
|
|
int xx = 0;
|
|
|
|
int nitems = 0;
|
|
|
|
for (int i = -11000; i < 11000; i += 110) {
|
|
|
|
++xx;
|
|
|
|
int yy = 0;
|
|
|
|
for (int j = -7000; j < 7000; j += 70) {
|
|
|
|
++yy;
|
|
|
|
qreal x = (i + 11000) / 22000.0;
|
|
|
|
qreal y = (j + 7000) / 14000.0;
|
|
|
|
|
|
|
|
QColor color(image.pixel(int(image.width() * x), int(image.height() * y)));
|
|
|
|
QGraphicsItem *item = new Chip(color, xx, yy);
|
|
|
|
item->setPos(QPointF(i, j));
|
|
|
|
scene->addItem(item);
|
|
|
|
|
|
|
|
++nitems;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|