From f66fc1db26af4bcc670a27011245090efc7e1686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borna=20Rajkovi=C4=87?= Date: Thu, 9 Jun 2022 20:24:27 +0200 Subject: [PATCH] Updated translations + bugfixes --- CMakeLists.txt | 2 +- SchemeEditor.pro | 71 ++++++++++--------- comdel/display/attribute_dialog.cpp | 20 +++--- comdel/display/attribute_dialog.h | 4 +- comdel/display/component_display.cpp | 42 ++++++----- comdel/display/library_display.cpp | 6 +- comdel/display/library_list.cpp | 2 +- comdel/display/schema_display.cpp | 34 +++++---- comdel/display/schema_display.h | 14 ++-- comdel/display/single_automatic_dialog.cpp | 6 +- comdel/display/single_automatic_dialog.h | 2 +- comdel/domain/comdel_validator.cpp | 2 +- comdel/domain/display.cpp | 15 +++- .../{comdellexer.cpp => comdel_lexer.cpp} | 2 +- .../parser/{comdellexer.h => comdel_lexer.h} | 0 comdel/parser/parser_util.cpp | 2 +- examples/simplified FRISC model/comdel.system | 27 ++----- examples/simplified FRISC model/schema4.csl | 26 +------ mainwindow.cpp | 32 +++++---- mainwindow.ui | 6 +- 20 files changed, 157 insertions(+), 158 deletions(-) rename comdel/parser/{comdellexer.cpp => comdel_lexer.cpp} (99%) rename comdel/parser/{comdellexer.h => comdel_lexer.h} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 885e484..4aeb9af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ add_executable(SchemeEditor comdel/parser/tokens_type.cpp comdel/parser/ast_nodes.cpp comdel/parser/parser_util.cpp - comdel/parser/comdellexer.cpp + comdel/parser/comdel_lexer.cpp main.cpp mainwindow.ui comdel/domain/comdel_validator.cpp comdel/domain/comdel_validator.h comdel/display/attribute_dialog.cpp comdel/display/attribute_dialog.h comdel/display/name_dialog.cpp comdel/display/name_dialog.h comdel/domain/comdel_generator.cpp comdel/domain/comdel_generator.h comdel/display/library_list.cpp comdel/display/library_list.h application.cpp application.h comdel/display/single_automatic_dialog.cpp comdel/display/single_automatic_dialog.h) diff --git a/SchemeEditor.pro b/SchemeEditor.pro index c608e2e..45e0ec9 100644 --- a/SchemeEditor.pro +++ b/SchemeEditor.pro @@ -9,77 +9,80 @@ CONFIG += c++17 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + comdel/display/attribute_dialog.cpp \ comdel/display/component_display.cpp \ comdel/display/library_display.cpp \ + comdel/display/library_list.cpp \ + comdel/display/name_dialog.cpp \ comdel/display/schema_display.cpp \ - comdel/domain/addressspace.cpp \ + comdel/display/single_automatic_dialog.cpp \ + comdel/domain/address_space.cpp \ comdel/domain/attribute.cpp \ comdel/domain/bus.cpp \ - comdel/domain/schemacreator.cpp \ + comdel/domain/comdel_generator.cpp \ + comdel/domain/comdel_validator.cpp \ comdel/domain/component.cpp \ comdel/domain/connection.cpp \ - comdel/domain/comdelvalidator.cpp \ - comdel/domain/connectioninstance.cpp \ + comdel/domain/connection_instance.cpp \ comdel/domain/display.cpp \ - comdel/domain/functionsignature.cpp \ + comdel/domain/function_signature.cpp \ comdel/domain/instance.cpp \ - comdel/domain/instanceattribute.cpp \ + comdel/domain/instance_attribute.cpp \ comdel/domain/library.cpp \ comdel/domain/pin.cpp \ comdel/domain/rule.cpp \ comdel/domain/schema.cpp \ + comdel/domain/schema_creator.cpp \ comdel/domain/value.cpp \ - comdel/domain/wireinstance.cpp \ - comdel/parser/astnode.cpp \ - comdel/parser/comdellexer.cpp \ - comdel/parser/comdelparser.cpp \ - comdel/parser/parsecontext.cpp \ - comdel/parser/parserutil.cpp \ - comdel/parser/sourceerror.cpp \ + comdel/parser/ast_nodes.cpp \ + comdel/parser/comdel_lexer.cpp \ + comdel/parser/comdel_parser.cpp \ + comdel/parser/parse_context.cpp \ + comdel/parser/parser_util.cpp \ + comdel/parser/source_error.cpp \ comdel/parser/token.cpp \ - comdel/parser/tokenstype.cpp \ - comdel/display/dialogmanager.cpp \ - comdel/display/attribute_dialog.cpp \ - comdel/display/name_dialog.cpp \ + comdel/parser/tokens_type.cpp \ + application.cpp \ main.cpp \ mainwindow.cpp HEADERS += \ + comdel/display/attribute_dialog.h \ comdel/display/component_display.h \ comdel/display/library_display.h \ + comdel/display/library_list.h \ + comdel/display/name_dialog.h \ comdel/display/schema_display.h \ - comdel/domain/addressspace.h \ + comdel/display/single_automatic_dialog.h \ + comdel/domain/address_space.h \ comdel/domain/attribute.h \ comdel/domain/bus.h \ - comdel/domain/schemacreator.h \ + comdel/domain/comdel_generator.h \ + comdel/domain/comdel_validator.h \ comdel/domain/component.h \ comdel/domain/connection.h \ - comdel/domain/comdelvalidator.h \ - comdel/domain/connectioninstance.h \ + comdel/domain/connection_instance.h \ comdel/domain/display.h \ - comdel/domain/functionsignature.h \ + comdel/domain/function_signature.h \ comdel/domain/instance.h \ - comdel/domain/instanceattribute.h \ + comdel/domain/instance_attribute.h \ comdel/domain/library.h \ comdel/domain/pin.h \ comdel/domain/rule.h \ comdel/domain/schema.h \ + comdel/domain/schema_creator.h \ comdel/domain/value.h \ - comdel/domain/wireinstance.h \ - comdel/parser/astnode.h \ - comdel/parser/comdellexer.h \ - comdel/parser/comdelparser.h \ + comdel/parser/ast_nodes.h \ + comdel/parser/comdel_lexer.h \ + comdel/parser/comdel_parser.h \ comdel/parser/expected.h \ - comdel/parser/parsecontext.h \ - comdel/parser/parserutil.h \ + comdel/parser/parse_context.h \ + comdel/parser/parser_util.h \ comdel/parser/poly.h \ comdel/parser/presult.h \ - comdel/parser/sourceerror.h \ + comdel/parser/source_error.h \ comdel/parser/token.h \ - comdel/parser/tokenstype.h \ - comdel/display/dialogmanager.h \ - comdel/display/attribute_dialog.h \ - comdel/display/name_dialog.h \ + comdel/parser/tokens_type.h \ mainwindow.h FORMS += \ diff --git a/comdel/display/attribute_dialog.cpp b/comdel/display/attribute_dialog.cpp index 35ebad1..60ce931 100644 --- a/comdel/display/attribute_dialog.cpp +++ b/comdel/display/attribute_dialog.cpp @@ -59,14 +59,16 @@ namespace display { } - AttributeDialog::AttributeDialog(domain::InstanceAttribute *attribute) { + AttributeDialog::AttributeDialog(domain::InstanceAttribute *attribute, bool updating) { setAttribute(Qt::WA_DeleteOnClose); attributeValue = attribute; - this->setWindowTitle(QString::fromStdString("Izmjeni " + attribute->attribute.getName())); + auto actionType = updating ? "Izmjeni " : "Postavi "; + + this->setWindowTitle(QString::fromStdString(actionType + attribute->attribute.getName())); auto layout = new QVBoxLayout(this); this->setLayout(layout); @@ -120,11 +122,11 @@ namespace display { auto *radioLayout = new QHBoxLayout(group); group->setLayout(radioLayout); - auto isTrue = new QRadioButton("true", group); + auto isTrue = new QRadioButton("da", group); connect(isTrue, &QRadioButton::clicked, [this]() { this->value = domain::Value::fromBool(true); }); - auto isFalse = new QRadioButton("false", group); + auto isFalse = new QRadioButton("ne", group); connect(isFalse, &QRadioButton::clicked, [this]() { this->value = domain::Value::fromBool(false); }); @@ -140,7 +142,7 @@ namespace display { layout->addWidget(group); } - auto button = new QPushButton("Ažuriraj"); + auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi"); connect(button, &QPushButton::clicked, this, &AttributeDialog::onUpdate); layout->addWidget(button); @@ -170,14 +172,16 @@ namespace display { } MemoryDialog::MemoryDialog(domain::InstanceAttribute *attribute, - std::vector> instances) { + std::vector> instances, bool updating) { memoryInstances = std::vector(); setAttribute(Qt::WA_DeleteOnClose); attributeValue = attribute; - this->setWindowTitle(QString::fromStdString("Izmjeni " + attribute->attribute.getName())); + auto actionType = updating ? "Izmjeni memoriju" : "Postavi memoriju"; + + this->setWindowTitle(QString::fromStdString(actionType)); for (auto &instance: instances) { if (instance->component.getType() == domain::Component::MEMORY) { @@ -212,7 +216,7 @@ namespace display { } } - auto button = new QPushButton("Ažuriraj"); + auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi"); connect(button, &QPushButton::clicked, this, &MemoryDialog::onUpdate); layout->addWidget(button); diff --git a/comdel/display/attribute_dialog.h b/comdel/display/attribute_dialog.h index 95c037e..1f7df1e 100644 --- a/comdel/display/attribute_dialog.h +++ b/comdel/display/attribute_dialog.h @@ -42,7 +42,7 @@ namespace display { domain::InstanceAttribute *attributeValue; public: - AttributeDialog(domain::InstanceAttribute *attribute); + AttributeDialog(domain::InstanceAttribute *attribute, bool updating = true); public slots: @@ -63,7 +63,7 @@ namespace display { public: MemoryDialog(domain::InstanceAttribute *attribute, - std::vector> instances); + std::vector> instances, bool updating = true); public slots: diff --git a/comdel/display/component_display.cpp b/comdel/display/component_display.cpp index dc77ac5..190dbc9 100644 --- a/comdel/display/component_display.cpp +++ b/comdel/display/component_display.cpp @@ -7,11 +7,15 @@ #include #include +#include #include #include + namespace display { + QPen connectionPen(QColor::fromRgb(150, 150, 250)); + void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu menu; menu.addAction("Izmjeni ime", [this]() { @@ -32,18 +36,20 @@ namespace display { auto *attr = &this->instance->attributes[i]; bool enabled = attr->attribute.getPopup().has_value(); - auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name), - [attr]() { - if (attr->value.getType() == domain::Value::MEMORY_REFERENCE) { - auto dialog = new MemoryDialog(attr, - Application::instance()->getSchema()->componentInstances); - dialog->exec(); - } else { - auto dialog = new AttributeDialog(attr); - dialog->exec(); - } - }); - action->setEnabled(enabled); + if(attr->value.getType() == domain::Value::MEMORY_REFERENCE) { + menu.addAction("Izmjeni memoriju", [attr]() { + auto dialog = new MemoryDialog(attr, + Application::instance()->getSchema()->componentInstances); + dialog->exec(); + }); + } else { + auto action = menu.addAction(QString::fromStdString("Izmjeni '" + attr->name + "'"), + [attr]() { + auto dialog = new AttributeDialog(attr); + dialog->exec(); + }); + action->setEnabled(enabled); + } } menu.addSeparator(); menu.addAction(QString::fromStdString("Ukloni " + this->instance->name), [this]() { @@ -62,7 +68,7 @@ namespace display { void Pin::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu menu; - menu.addAction("Connect pin", [&]() {}); + menu.addAction("Poveži pin", [&]() {}); menu.exec(event->screenPos()); } @@ -75,6 +81,8 @@ namespace display { QPointF(pin.getDisplayPin().getConnectionX(), pin.getDisplayPin().getConnectionY()); view->context.line = new QGraphicsLineItem(QLineF(view->context.startingPoint, event->scenePos())); + view->context.line->setPen(QPen(QColor::fromRgb(100, 100, 250), 1, Qt::PenStyle::DashLine)); + view->context.line->setZValue(1000); this->scene()->addItem(view->context.line); view->showConnectable(this); @@ -225,9 +233,8 @@ namespace display { BusConnection::BusConnection(domain::BusConnectionInstance *connection, ComponentGroup *component, BusGroup *bus): connection( connection), component(component), bus(bus) { updateConnection(); - - setCursor(Qt::CrossCursor); - + setPen(connectionPen); + setZValue(-1); setHandlesChildEvents(false); } @@ -280,7 +287,8 @@ namespace display { DirectConnection::DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first, ComponentGroup *second): connection(connection), first(first), second(second) { updateConnection(); - setCursor(Qt::CrossCursor); + setPen(connectionPen); + setZValue(-1); setHandlesChildEvents(false); } diff --git a/comdel/display/library_display.cpp b/comdel/display/library_display.cpp index 8af2765..d362571 100644 --- a/comdel/display/library_display.cpp +++ b/comdel/display/library_display.cpp @@ -14,11 +14,11 @@ namespace display { componentList = new LibraryList(this); busList = new LibraryList(this); - layout->setMargin(4); - layout->addWidget(new QLabel("Components:")); + layout->setContentsMargins(4, 4, 4, 4); + layout->addWidget(new QLabel("Komponente:")); layout->addWidget(componentList, 1); layout->addSpacing(8); - layout->addWidget(new QLabel("Buses:")); + layout->addWidget(new QLabel("Sabirnice:")); layout->addWidget(busList, 1); } diff --git a/comdel/display/library_list.cpp b/comdel/display/library_list.cpp index ec766ff..372b830 100644 --- a/comdel/display/library_list.cpp +++ b/comdel/display/library_list.cpp @@ -29,4 +29,4 @@ namespace display { : QListWidgetItem(parent), mimeType(mimeType), value(value) { setText(QString::fromStdString(title)); } -} // display \ No newline at end of file +} // display diff --git a/comdel/display/schema_display.cpp b/comdel/display/schema_display.cpp index 6e85831..b49c253 100644 --- a/comdel/display/schema_display.cpp +++ b/comdel/display/schema_display.cpp @@ -11,8 +11,6 @@ namespace display { Schema::Schema() { - this->selectedBrush.setColor(QColor::fromRgb(20, 20, 125)); - this->selectedPen.setColor(QColor::fromRgb(20, 20, 125)); schema = nullptr; library = std::nullopt; this->setScene(&scene); @@ -27,7 +25,9 @@ namespace display { components.clear(); buses.clear(); scene.clear(); + pins.clear(); busConnections.clear(); + directConnections.clear(); if (schema != nullptr) { for (auto &instance: schema->componentInstances) { @@ -150,6 +150,7 @@ namespace display { if (con.has_value()) { auto attributes = populateAttributes(con->getAttributes()); if(attributes.size() != con->getAttributes().size()) { + clearSelectable(); return; } @@ -190,6 +191,7 @@ namespace display { attributes = populateAttributes(con->getAttributes()); } if(attributes.size() != con->getAttributes().size()) { + clearSelectable(); return; } @@ -211,14 +213,7 @@ namespace display { } } - updateConnections(); - - - for (auto &item: this->context.selectable) { - this->scene.removeItem(item); - delete item; - } - this->context.selectable.clear(); + clearSelectable(); } void Schema::showConnectable(Pin *domainPin) { @@ -236,7 +231,7 @@ namespace display { continue; } auto rect = new QGraphicsRectItem(group->boundingRect()); - rect->setPen(selectedPen); + rect->setBrush(selectedBrush); rect->setPos(group->scenePos()); auto _rect = rect->rect(); @@ -255,6 +250,7 @@ namespace display { auto pinInstance = domain::ConnectionComponent{connection.componentInstance.value()->name, connection.pin.value().getName()}; auto &instance = pins[pinInstance]; auto rect = new QGraphicsRectItem(instance->boundingRect()); + rect->setBrush(selectedBrush); rect->setPen(selectedPen); rect->setPos(instance->scenePos()); @@ -276,13 +272,13 @@ namespace display { domain::InstanceAttribute attribute(attr.getName(), attr.getDefault(), attr); if(attr.getPopup().has_value() && attr.getPopup()->getType() == domain::Popup::AUTOMATIC) { if(attr.getDefault().isType(domain::Value::MEMORY_REFERENCE)) { - auto dialog = new MemoryDialog(&attribute, schema->componentInstances); + auto dialog = new MemoryDialog(&attribute, schema->componentInstances, false); if(dialog->exec() == QDialog::Rejected) { // if any dialog isn't set, whole creation is rejected return {}; } } else { - auto dialog = new AttributeDialog(&attribute); + auto dialog = new AttributeDialog(&attribute, false); if(dialog->exec() == QDialog::Rejected) { // if any dialog isn't set, whole creation is rejected return {}; @@ -301,7 +297,7 @@ namespace display { instanceAttributes.emplace_back(attr.getName(), attr.getDefault(), attr); } - auto dialog = new display::SingleAutomaticDialog(instanceAttributes); + auto dialog = new display::SingleAutomaticDialog(instanceAttributes, false); if(dialog->exec() == QDialog::Rejected) { // if dialog is rejected, whole creation is rejected return {}; @@ -311,4 +307,14 @@ namespace display { } + void Schema::clearSelectable() { + updateConnections(); + + for (auto &item: this->context.selectable) { + this->scene.removeItem(item); + delete item; + } + this->context.selectable.clear(); + } + } // namespace display diff --git a/comdel/display/schema_display.h b/comdel/display/schema_display.h index df4bd67..e844388 100644 --- a/comdel/display/schema_display.h +++ b/comdel/display/schema_display.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -19,8 +20,9 @@ namespace display { public: - QBrush selectedBrush; - QPen selectedPen; + QBrush selectedBrush = QBrush(QColor::fromRgb(50, 50, 150, 100), Qt::BrushStyle::SolidPattern); + QPen selectedPen = QPen(QColor::fromRgb(50, 50, 150), 1, Qt::PenStyle::SolidLine); + QPen activeLinePen = QPen(QColor::fromRgb(250, 100, 100)); enum State { DEFAULT, @@ -68,15 +70,11 @@ namespace display { domain::Schema *schema{}; std::optional library; - std::vector - getAvailableConnectionBusses(domain::ComponentInstance *instance, domain::Pin &pin); - - std::vector - getAvailableConnectionPins(domain::ComponentInstance *instance, domain::Pin &pin); - std::vector populateAttributes(std::vector& attributes); std::vector populateSingleAutomaticConnection(domain::Connection connection); + + void clearSelectable(); }; } // namespace display diff --git a/comdel/display/single_automatic_dialog.cpp b/comdel/display/single_automatic_dialog.cpp index 5605e79..f478bf2 100644 --- a/comdel/display/single_automatic_dialog.cpp +++ b/comdel/display/single_automatic_dialog.cpp @@ -9,9 +9,9 @@ #include namespace display { - SingleAutomaticDialog::SingleAutomaticDialog(std::vector &values): attributes(values) { + SingleAutomaticDialog::SingleAutomaticDialog(std::vector &values, bool updating): attributes(values) { setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle(QString::fromStdString("Postavi poveznicu")); + setWindowTitle(QString::fromStdString(updating ? "Ažuriraj poveznicu" : "Postavi poveznicu")); firstValue = values[0].value; secondValue = values[1].value; @@ -29,7 +29,7 @@ namespace display { setupValues(firstLayout, values[0], &SingleAutomaticDialog::onFirstEnumerationChanged); setupValues(secondLayout, values[1], &SingleAutomaticDialog::onSecondEnumerationChanged); - auto button = new QPushButton("Ažuriraj"); + auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi"); connect(button, &QPushButton::clicked, this, &SingleAutomaticDialog::onUpdate); parentLayout->addWidget(button); } diff --git a/comdel/display/single_automatic_dialog.h b/comdel/display/single_automatic_dialog.h index cc05d28..8689188 100644 --- a/comdel/display/single_automatic_dialog.h +++ b/comdel/display/single_automatic_dialog.h @@ -19,7 +19,7 @@ namespace display { std::vector &attributes; public: - explicit SingleAutomaticDialog(std::vector& values); + explicit SingleAutomaticDialog(std::vector& values, bool updating = true); void setupValues(QVBoxLayout *layout, domain::InstanceAttribute &attribute, void (display::SingleAutomaticDialog::* handler)(int)); diff --git a/comdel/domain/comdel_validator.cpp b/comdel/domain/comdel_validator.cpp index 187fe09..c64188c 100644 --- a/comdel/domain/comdel_validator.cpp +++ b/comdel/domain/comdel_validator.cpp @@ -172,7 +172,7 @@ namespace domain { if(memoryReference != nullopt) { if(memoryInstances.count(*memoryReference) == 0) { context.attributes["memoryReference"] = domain::Value::fromString(memoryReference.value()); - auto message = populateMessage("There isn't a memory instance '{memoryReference}'", context); + auto message = populateMessage("Ne postoji memorijska komponenta '{memoryReference}'", context); errors.emplace_back(component.get(), nullptr, Action::ERROR, message); } } diff --git a/comdel/domain/display.cpp b/comdel/domain/display.cpp index a5ee669..985edd7 100644 --- a/comdel/domain/display.cpp +++ b/comdel/domain/display.cpp @@ -1,7 +1,13 @@ #include "display.h" +#include +#include + namespace domain { + QBrush busBrush(QColor::fromRgb(200, 200, 200)); + QPen busPen(QColor::fromRgb(200, 200, 200)); + Display::Display(std::vector items) : items(items) {} void Display::render(QGraphicsItemGroup *group) { @@ -39,11 +45,16 @@ namespace domain { } void ui::Bus::render(QGraphicsItemGroup *group, int size) { + int _w = w, _h = h; if (orientation == HORIZONTAL) { - group->addToGroup(new QGraphicsRectItem(x, y, size, h)); + _w = size; } else { - group->addToGroup(new QGraphicsRectItem(x, y, w, size)); + _h = size; } + auto rect = new QGraphicsRectItem(x, y, _w, _h); + rect->setBrush(busBrush); + rect->setPen(busPen); + group->addToGroup(rect); } int ui::Bus::getDefaultSize() { diff --git a/comdel/parser/comdellexer.cpp b/comdel/parser/comdel_lexer.cpp similarity index 99% rename from comdel/parser/comdellexer.cpp rename to comdel/parser/comdel_lexer.cpp index bbecfab..d2014e0 100644 --- a/comdel/parser/comdellexer.cpp +++ b/comdel/parser/comdel_lexer.cpp @@ -1,4 +1,4 @@ -#include "comdellexer.h" +#include "comdel_lexer.h" #include "token.h" #include "tokens_type.h" diff --git a/comdel/parser/comdellexer.h b/comdel/parser/comdel_lexer.h similarity index 100% rename from comdel/parser/comdellexer.h rename to comdel/parser/comdel_lexer.h diff --git a/comdel/parser/parser_util.cpp b/comdel/parser/parser_util.cpp index 8b1ad1b..6497b8b 100644 --- a/comdel/parser/parser_util.cpp +++ b/comdel/parser/parser_util.cpp @@ -1,4 +1,4 @@ -#include "comdellexer.h" +#include "comdel_lexer.h" #include "comdel_parser.h" #include "parser_util.h" diff --git a/examples/simplified FRISC model/comdel.system b/examples/simplified FRISC model/comdel.system index f9fa11d..d057741 100644 --- a/examples/simplified FRISC model/comdel.system +++ b/examples/simplified FRISC model/comdel.system @@ -1,6 +1,5 @@ // Version 0.0.1 #include "libraries\frisc\vjezba1\FRISC.cdl" -#include "libraries\frisc\vjezba1\dma.cdl" #include "libraries\frisc\vjezba1\memory.cdl" @@ -24,43 +23,31 @@ component System wire --BACK; - //PIOSabirnica - wire<8> PIO_DATA; - wire READY; - wire STROBE; - - //directRam wire INT; // components -------------------------------------------- - subcomponent Memorija memorija(ADR, DATA, READ, WRITE, SIZE, WAIT, INT, *, *, *); + subcomponent Memorija memorija(ADR, DATA, READ, WRITE, SIZE, WAIT, *, *, *, INT); subcomponent FRISC procesor(ADR, DATA, READ, WRITE, SIZE, WAIT, INT0, INT1, INT2, INT3, --IACK, 1, *, INT, *, *, *); - subcomponent DMA dma<1024>(ADR, DATA, READ, WRITE, SIZE, WAIT, INT0, --BREQ, --BACK, 0, 0, *, *); display { - component { x: -104; y: -102; ref: "procesor"; } - component { x: 39; y: 199; ref: "memorija"; } - component { x: -352; y: 13; ref: "dma"; } + component { x: -377; y: -302; ref: "procesor"; } + component { x: -56; y: -80; ref: "memorija"; } // glavnaSabirnica bus rectangle { - x: -106; y: 80; + x: -377; y: -106; w: 100; h: 20; } - // PIOSabirnica bus - - // directRam bus - line {x1:-54; y1:14; x2:-55; y2:90;} - line {x1:89; y1:183; x2:-55; y2:90;} - line {x1:-244; y1:79; x2:-55; y2:90;} - line {x1:23; y1:227; x2:12; y2:-52;} + line {x1:-6; y1:-96; x2:-326; y2:-95;} + line {x1:-327; y1:-186; x2:-326; y2:-95;} + line {x1:-72; y1:-52; x2:-261; y2:-252;} } } \ No newline at end of file diff --git a/examples/simplified FRISC model/schema4.csl b/examples/simplified FRISC model/schema4.csl index 33e3541..c2d32e3 100644 --- a/examples/simplified FRISC model/schema4.csl +++ b/examples/simplified FRISC model/schema4.csl @@ -2,35 +2,15 @@ @schema { @instance procesor FRISC { - @position (-162, -117) + @position (-543, -304) @attribute _memory null } - @instance dma DMA { - @position (-393, -26) - @attribute pocetnaAdresa 0 - } - @instance glavnaSabirnica glavnaSabirnica { - @position (-155, 49) + @position (-544, -91) @size 100 } - @instance PIOSabirnica PIOSabirnica { - @position (0, 0) - @size 0 - } - - @instance PIOSabirnica PIOSabirnica { - @position (0, 0) - @size 0 - } - - @connection (dma.glavniPin, PIOSabirnica, procesor.glavniPin) { - } - @connection (dma.glavniPin, glavnaSabirnica) { - @attribute interupt 1 - } - @connection (dma.glavniPin, PIOSabirnica, procesor.glavniPin) { + @connection (procesor.glavniPin, glavnaSabirnica) { } } diff --git a/mainwindow.cpp b/mainwindow.cpp index fba4ca6..7c1ab3d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -32,11 +32,13 @@ void MainWindow::setupUi() ui->centralwidget->setLayout(layout); // setup toolbar - ui->toolBar->addAction("Load library", this, &MainWindow::onLoadLibrary); - ui->toolBar->addAction("Load schema", this, &MainWindow::onLoadSchema); - ui->toolBar->addAction("Save schema", this, &MainWindow::onStoreScheme); - ui->toolBar->addAction("Generate system", this, &MainWindow::onGenerateComdel); + ui->toolBar->addAction("Učitaj bibiloteku", this, &MainWindow::onLoadLibrary); + ui->toolBar->addAction("Učitaj shemu", this, &MainWindow::onLoadSchema); + ui->toolBar->addAction("Spremi shemu", this, &MainWindow::onStoreScheme); + ui->toolBar->addAction("Generiraj comdel", this, &MainWindow::onGenerateComdel); + connect(ui->actionSave_schema, &QAction::triggered, this, &MainWindow::onStoreScheme); + connect(ui->actionExport_schema, &QAction::triggered, this, &MainWindow::onGenerateComdel); connect(ui->actionValidate, &QAction::triggered, this, &MainWindow::onValidateSchema); // setup central content @@ -47,10 +49,10 @@ void MainWindow::setupUi() schemaParent->setLayout(schemaLayout); schemaDisplay = new display::Schema(); - schemaLayout->setMargin(0); + schemaLayout->setContentsMargins(0, 0, 0, 0); schemaLayout->addWidget(schemaDisplay, 1); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(libraryDisplay); layout->addWidget(schemaParent, 1); @@ -62,7 +64,7 @@ void MainWindow::setupUi() void MainWindow::onLoadLibrary() { auto filename = QFileDialog::getOpenFileName(this, - tr("Open library"), "/home", tr("Comdel library (*.csl)")); + tr("Otvori biblioteku"), "", tr("Comdel biblioteka (*.csl)")); if(!filename.isEmpty()) { std::ostringstream output; log->clear(); @@ -81,7 +83,7 @@ void MainWindow::onLoadLibrary() { void MainWindow::onLoadSchema() { auto filename = QFileDialog::getOpenFileName(this, - tr("Open schema"), "/home", tr("Comdel schema (*.csl)")); + tr("Otvori shemu"), "", tr("Comdel shema (*.csl)")); if(!filename.isEmpty()) { std::ostringstream output; log->clear(); @@ -102,7 +104,7 @@ void MainWindow::onLoadSchema() { void MainWindow::onStoreScheme() { auto filename = QFileDialog::getSaveFileName(this, - tr("Save schema"), "/home", tr("Comdel schema (*.csl)")); + tr("Spremi shemu"), "", tr("Comdel shema (*.csl)")); if(!filename.isEmpty()) { log->clear(); @@ -113,9 +115,9 @@ void MainWindow::onStoreScheme() { out<appendPlainText("Successfully stored schema\n"); + log->appendPlainText("Uspješno spremljena shema\n"); } else { - log->appendPlainText("Failed storing schema\n"); + log->appendPlainText("Greška tijekom spremanja sheme\n"); } } @@ -123,7 +125,7 @@ void MainWindow::onStoreScheme() { void MainWindow::onGenerateComdel() { auto filename = QFileDialog::getSaveFileName(this, - tr("Save schema"), "/home", tr("Comdel system (*.system)")); + tr("Spremi shemu"), "", tr("Comdel sustav (*.system)")); if(!filename.isEmpty()) { log->clear(); @@ -140,9 +142,9 @@ void MainWindow::onGenerateComdel() { out<appendPlainText("Successfully generated comdel\n"); + log->appendPlainText("Uspješno generiranje comdel modela\n"); } else { - log->appendPlainText("Failed generating comdel\n"); + log->appendPlainText("Neuspješno generiranje comdel modela\n"); } } } @@ -181,4 +183,4 @@ void MainWindow::formatErrors(std::vector& errors, std: MainWindow::~MainWindow() { delete ui; -} \ No newline at end of file +} diff --git a/mainwindow.ui b/mainwindow.ui index 5095e83..abd3330 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -53,17 +53,17 @@ - Save schema + Spremi shemu - Export schema + Generiraj comdel - Validate + Validairaj