aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-12-21 15:01:18 +0100
committerKarel Kočí <cynerd@email.cz>2017-12-21 15:01:18 +0100
commit1008f8180161b3ab7c6b885cb6f6a19df59dd398 (patch)
tree17250b4cc966333b173b1ba08ec863da5ec712ff /qtmips_gui/coreview.cpp
parentf1c0203237b976c366bedd950a2e6ffbcb8f7bcd (diff)
downloadqtmips-1008f8180161b3ab7c6b885cb6f6a19df59dd398.tar.gz
qtmips-1008f8180161b3ab7c6b885cb6f6a19df59dd398.tar.bz2
qtmips-1008f8180161b3ab7c6b885cb6f6a19df59dd398.zip
A lot of small changes in gui
Added machine status. Widgets now hold size and registers dock has now scrollbars. And more...
Diffstat (limited to 'qtmips_gui/coreview.cpp')
-rw-r--r--qtmips_gui/coreview.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index b7c17fc..f7cc416 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -1,14 +1,23 @@
#include "coreview.h"
-CoreView::CoreView(QWidget *parent, machine::QtMipsMachine *machine) : QGraphicsView(parent) {
+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
- scene.addLine(400, 0, 400, 800);
- scene.addLine(0, 400, 800, 400);
+ addLine(400, 0, 400, 800);
+ addLine(0, 400, 800, 400);
pc = new coreview::ProgramCounter(machine);
alu = new coreview::Alu();
@@ -17,22 +26,19 @@ CoreView::CoreView(QWidget *parent, machine::QtMipsMachine *machine) : QGraphics
pc2pc = new coreview::Connection(pc_multiplexer->connector_out(), pc->connector_in());
- scene.addItem(pc);
- scene.addItem(alu);
- scene.addItem(pc_multiplexer);
- scene.addItem(testlatch);
- scene.addItem(pc2pc);
+ 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);
- setScene(&scene);
- // 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);
+ QGraphicsScene *old_scene = view->scene();
+ view->setScene(this);
+ if (old_scene != nullptr)
+ delete old_scene;
}