aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview.cpp
blob: f7cc4165c66c34e2ce15655cf26258a3cd23d465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "coreview.h"

CoreView::CoreView(QWidget *parent) : QGraphicsView(parent) {
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);

    // TODO fitInView doesn't work as I want so reimplement or do something with it
    //fitInView(0, 0, 201, 201, Qt::KeepAspectRatioByExpanding);
}

void CoreView::resizeEvent(QResizeEvent *event) {
    // fitInView(0, 0, 201, 201, Qt::KeepAspectRatioByExpanding);
}

CoreViewScene::CoreViewScene(CoreView *view, machine::QtMipsMachine *machine) : QGraphicsScene(view) {
    this->machine = machine;
    // Identification cross
    addLine(400, 0, 400, 800);
    addLine(0, 400, 800, 400);

    pc = new coreview::ProgramCounter(machine);
    alu = new coreview::Alu();
    pc_multiplexer = new coreview::Multiplexer(4);
    testlatch = new coreview::Latch(machine, 300);

    pc2pc = new coreview::Connection(pc_multiplexer->connector_out(), pc->connector_in());

    addItem(pc);
    addItem(alu);
    addItem(pc_multiplexer);
    addItem(testlatch);
    addItem(pc2pc);

    pc->setPos(100,100);
    alu->setPos(200, 100);
    pc_multiplexer->setPos(60, 100);
    pc_multiplexer->set(2);

    QGraphicsScene *old_scene = view->scene();
    view->setScene(this);
    if (old_scene != nullptr)
        delete old_scene;
}