Updated translations + bugfixes

This commit is contained in:
Borna Rajković 2022-06-09 20:24:27 +02:00
parent 1759adf25a
commit f66fc1db26
20 changed files with 157 additions and 158 deletions

View File

@ -34,7 +34,7 @@ add_executable(SchemeEditor
comdel/parser/tokens_type.cpp comdel/parser/tokens_type.cpp
comdel/parser/ast_nodes.cpp comdel/parser/ast_nodes.cpp
comdel/parser/parser_util.cpp comdel/parser/parser_util.cpp
comdel/parser/comdellexer.cpp comdel/parser/comdel_lexer.cpp
main.cpp main.cpp
mainwindow.ui 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) 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)

View File

@ -9,77 +9,80 @@ CONFIG += c++17
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \ SOURCES += \
comdel/display/attribute_dialog.cpp \
comdel/display/component_display.cpp \ comdel/display/component_display.cpp \
comdel/display/library_display.cpp \ comdel/display/library_display.cpp \
comdel/display/library_list.cpp \
comdel/display/name_dialog.cpp \
comdel/display/schema_display.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/attribute.cpp \
comdel/domain/bus.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/component.cpp \
comdel/domain/connection.cpp \ comdel/domain/connection.cpp \
comdel/domain/comdelvalidator.cpp \ comdel/domain/connection_instance.cpp \
comdel/domain/connectioninstance.cpp \
comdel/domain/display.cpp \ comdel/domain/display.cpp \
comdel/domain/functionsignature.cpp \ comdel/domain/function_signature.cpp \
comdel/domain/instance.cpp \ comdel/domain/instance.cpp \
comdel/domain/instanceattribute.cpp \ comdel/domain/instance_attribute.cpp \
comdel/domain/library.cpp \ comdel/domain/library.cpp \
comdel/domain/pin.cpp \ comdel/domain/pin.cpp \
comdel/domain/rule.cpp \ comdel/domain/rule.cpp \
comdel/domain/schema.cpp \ comdel/domain/schema.cpp \
comdel/domain/schema_creator.cpp \
comdel/domain/value.cpp \ comdel/domain/value.cpp \
comdel/domain/wireinstance.cpp \ comdel/parser/ast_nodes.cpp \
comdel/parser/astnode.cpp \ comdel/parser/comdel_lexer.cpp \
comdel/parser/comdellexer.cpp \ comdel/parser/comdel_parser.cpp \
comdel/parser/comdelparser.cpp \ comdel/parser/parse_context.cpp \
comdel/parser/parsecontext.cpp \ comdel/parser/parser_util.cpp \
comdel/parser/parserutil.cpp \ comdel/parser/source_error.cpp \
comdel/parser/sourceerror.cpp \
comdel/parser/token.cpp \ comdel/parser/token.cpp \
comdel/parser/tokenstype.cpp \ comdel/parser/tokens_type.cpp \
comdel/display/dialogmanager.cpp \ application.cpp \
comdel/display/attribute_dialog.cpp \
comdel/display/name_dialog.cpp \
main.cpp \ main.cpp \
mainwindow.cpp mainwindow.cpp
HEADERS += \ HEADERS += \
comdel/display/attribute_dialog.h \
comdel/display/component_display.h \ comdel/display/component_display.h \
comdel/display/library_display.h \ comdel/display/library_display.h \
comdel/display/library_list.h \
comdel/display/name_dialog.h \
comdel/display/schema_display.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/attribute.h \
comdel/domain/bus.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/component.h \
comdel/domain/connection.h \ comdel/domain/connection.h \
comdel/domain/comdelvalidator.h \ comdel/domain/connection_instance.h \
comdel/domain/connectioninstance.h \
comdel/domain/display.h \ comdel/domain/display.h \
comdel/domain/functionsignature.h \ comdel/domain/function_signature.h \
comdel/domain/instance.h \ comdel/domain/instance.h \
comdel/domain/instanceattribute.h \ comdel/domain/instance_attribute.h \
comdel/domain/library.h \ comdel/domain/library.h \
comdel/domain/pin.h \ comdel/domain/pin.h \
comdel/domain/rule.h \ comdel/domain/rule.h \
comdel/domain/schema.h \ comdel/domain/schema.h \
comdel/domain/schema_creator.h \
comdel/domain/value.h \ comdel/domain/value.h \
comdel/domain/wireinstance.h \ comdel/parser/ast_nodes.h \
comdel/parser/astnode.h \ comdel/parser/comdel_lexer.h \
comdel/parser/comdellexer.h \ comdel/parser/comdel_parser.h \
comdel/parser/comdelparser.h \
comdel/parser/expected.h \ comdel/parser/expected.h \
comdel/parser/parsecontext.h \ comdel/parser/parse_context.h \
comdel/parser/parserutil.h \ comdel/parser/parser_util.h \
comdel/parser/poly.h \ comdel/parser/poly.h \
comdel/parser/presult.h \ comdel/parser/presult.h \
comdel/parser/sourceerror.h \ comdel/parser/source_error.h \
comdel/parser/token.h \ comdel/parser/token.h \
comdel/parser/tokenstype.h \ comdel/parser/tokens_type.h \
comdel/display/dialogmanager.h \
comdel/display/attribute_dialog.h \
comdel/display/name_dialog.h \
mainwindow.h mainwindow.h
FORMS += \ FORMS += \

View File

@ -59,14 +59,16 @@ namespace display {
} }
AttributeDialog::AttributeDialog(domain::InstanceAttribute *attribute) { AttributeDialog::AttributeDialog(domain::InstanceAttribute *attribute, bool updating) {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
attributeValue = attribute; 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); auto layout = new QVBoxLayout(this);
this->setLayout(layout); this->setLayout(layout);
@ -120,11 +122,11 @@ namespace display {
auto *radioLayout = new QHBoxLayout(group); auto *radioLayout = new QHBoxLayout(group);
group->setLayout(radioLayout); group->setLayout(radioLayout);
auto isTrue = new QRadioButton("true", group); auto isTrue = new QRadioButton("da", group);
connect(isTrue, &QRadioButton::clicked, [this]() { connect(isTrue, &QRadioButton::clicked, [this]() {
this->value = domain::Value::fromBool(true); this->value = domain::Value::fromBool(true);
}); });
auto isFalse = new QRadioButton("false", group); auto isFalse = new QRadioButton("ne", group);
connect(isFalse, &QRadioButton::clicked, [this]() { connect(isFalse, &QRadioButton::clicked, [this]() {
this->value = domain::Value::fromBool(false); this->value = domain::Value::fromBool(false);
}); });
@ -140,7 +142,7 @@ namespace display {
layout->addWidget(group); layout->addWidget(group);
} }
auto button = new QPushButton("Ažuriraj"); auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi");
connect(button, &QPushButton::clicked, this, &AttributeDialog::onUpdate); connect(button, &QPushButton::clicked, this, &AttributeDialog::onUpdate);
layout->addWidget(button); layout->addWidget(button);
@ -170,14 +172,16 @@ namespace display {
} }
MemoryDialog::MemoryDialog(domain::InstanceAttribute *attribute, MemoryDialog::MemoryDialog(domain::InstanceAttribute *attribute,
std::vector<std::shared_ptr<domain::ComponentInstance>> instances) { std::vector<std::shared_ptr<domain::ComponentInstance>> instances, bool updating) {
memoryInstances = std::vector<std::string>(); memoryInstances = std::vector<std::string>();
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
attributeValue = attribute; 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) { for (auto &instance: instances) {
if (instance->component.getType() == domain::Component::MEMORY) { 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); connect(button, &QPushButton::clicked, this, &MemoryDialog::onUpdate);
layout->addWidget(button); layout->addWidget(button);

View File

@ -42,7 +42,7 @@ namespace display {
domain::InstanceAttribute *attributeValue; domain::InstanceAttribute *attributeValue;
public: public:
AttributeDialog(domain::InstanceAttribute *attribute); AttributeDialog(domain::InstanceAttribute *attribute, bool updating = true);
public slots: public slots:
@ -63,7 +63,7 @@ namespace display {
public: public:
MemoryDialog(domain::InstanceAttribute *attribute, MemoryDialog(domain::InstanceAttribute *attribute,
std::vector<std::shared_ptr<domain::ComponentInstance>> instances); std::vector<std::shared_ptr<domain::ComponentInstance>> instances, bool updating = true);
public slots: public slots:

View File

@ -7,11 +7,15 @@
#include <QMenu> #include <QMenu>
#include <QLine> #include <QLine>
#include <QPen>
#include <QGraphicsSceneContextMenuEvent> #include <QGraphicsSceneContextMenuEvent>
#include <set> #include <set>
namespace display { namespace display {
QPen connectionPen(QColor::fromRgb(150, 150, 250));
void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
QMenu menu; QMenu menu;
menu.addAction("Izmjeni ime", [this]() { menu.addAction("Izmjeni ime", [this]() {
@ -32,18 +36,20 @@ namespace display {
auto *attr = &this->instance->attributes[i]; auto *attr = &this->instance->attributes[i];
bool enabled = attr->attribute.getPopup().has_value(); bool enabled = attr->attribute.getPopup().has_value();
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name), if(attr->value.getType() == domain::Value::MEMORY_REFERENCE) {
[attr]() { menu.addAction("Izmjeni memoriju", [attr]() {
if (attr->value.getType() == domain::Value::MEMORY_REFERENCE) { auto dialog = new MemoryDialog(attr,
auto dialog = new MemoryDialog(attr, Application::instance()->getSchema()->componentInstances);
Application::instance()->getSchema()->componentInstances); dialog->exec();
dialog->exec(); });
} else { } else {
auto dialog = new AttributeDialog(attr); auto action = menu.addAction(QString::fromStdString("Izmjeni '" + attr->name + "'"),
dialog->exec(); [attr]() {
} auto dialog = new AttributeDialog(attr);
}); dialog->exec();
action->setEnabled(enabled); });
action->setEnabled(enabled);
}
} }
menu.addSeparator(); menu.addSeparator();
menu.addAction(QString::fromStdString("Ukloni " + this->instance->name), [this]() { menu.addAction(QString::fromStdString("Ukloni " + this->instance->name), [this]() {
@ -62,7 +68,7 @@ namespace display {
void Pin::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { void Pin::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
QMenu menu; QMenu menu;
menu.addAction("Connect pin", [&]() {}); menu.addAction("Poveži pin", [&]() {});
menu.exec(event->screenPos()); menu.exec(event->screenPos());
} }
@ -75,6 +81,8 @@ namespace display {
QPointF(pin.getDisplayPin().getConnectionX(), QPointF(pin.getDisplayPin().getConnectionX(),
pin.getDisplayPin().getConnectionY()); pin.getDisplayPin().getConnectionY());
view->context.line = new QGraphicsLineItem(QLineF(view->context.startingPoint, event->scenePos())); 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); this->scene()->addItem(view->context.line);
view->showConnectable(this); view->showConnectable(this);
@ -225,9 +233,8 @@ namespace display {
BusConnection::BusConnection(domain::BusConnectionInstance *connection, ComponentGroup *component, BusGroup *bus): connection( BusConnection::BusConnection(domain::BusConnectionInstance *connection, ComponentGroup *component, BusGroup *bus): connection(
connection), component(component), bus(bus) { connection), component(component), bus(bus) {
updateConnection(); updateConnection();
setPen(connectionPen);
setCursor(Qt::CrossCursor); setZValue(-1);
setHandlesChildEvents(false); setHandlesChildEvents(false);
} }
@ -280,7 +287,8 @@ namespace display {
DirectConnection::DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first, DirectConnection::DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first,
ComponentGroup *second): connection(connection), first(first), second(second) { ComponentGroup *second): connection(connection), first(first), second(second) {
updateConnection(); updateConnection();
setCursor(Qt::CrossCursor); setPen(connectionPen);
setZValue(-1);
setHandlesChildEvents(false); setHandlesChildEvents(false);
} }

View File

@ -14,11 +14,11 @@ namespace display {
componentList = new LibraryList(this); componentList = new LibraryList(this);
busList = new LibraryList(this); busList = new LibraryList(this);
layout->setMargin(4); layout->setContentsMargins(4, 4, 4, 4);
layout->addWidget(new QLabel("Components:")); layout->addWidget(new QLabel("Komponente:"));
layout->addWidget(componentList, 1); layout->addWidget(componentList, 1);
layout->addSpacing(8); layout->addSpacing(8);
layout->addWidget(new QLabel("Buses:")); layout->addWidget(new QLabel("Sabirnice:"));
layout->addWidget(busList, 1); layout->addWidget(busList, 1);
} }

View File

@ -11,8 +11,6 @@
namespace display { namespace display {
Schema::Schema() { Schema::Schema() {
this->selectedBrush.setColor(QColor::fromRgb(20, 20, 125));
this->selectedPen.setColor(QColor::fromRgb(20, 20, 125));
schema = nullptr; schema = nullptr;
library = std::nullopt; library = std::nullopt;
this->setScene(&scene); this->setScene(&scene);
@ -27,7 +25,9 @@ namespace display {
components.clear(); components.clear();
buses.clear(); buses.clear();
scene.clear(); scene.clear();
pins.clear();
busConnections.clear(); busConnections.clear();
directConnections.clear();
if (schema != nullptr) { if (schema != nullptr) {
for (auto &instance: schema->componentInstances) { for (auto &instance: schema->componentInstances) {
@ -150,6 +150,7 @@ namespace display {
if (con.has_value()) { if (con.has_value()) {
auto attributes = populateAttributes(con->getAttributes()); auto attributes = populateAttributes(con->getAttributes());
if(attributes.size() != con->getAttributes().size()) { if(attributes.size() != con->getAttributes().size()) {
clearSelectable();
return; return;
} }
@ -190,6 +191,7 @@ namespace display {
attributes = populateAttributes(con->getAttributes()); attributes = populateAttributes(con->getAttributes());
} }
if(attributes.size() != con->getAttributes().size()) { if(attributes.size() != con->getAttributes().size()) {
clearSelectable();
return; return;
} }
@ -211,14 +213,7 @@ namespace display {
} }
} }
updateConnections(); clearSelectable();
for (auto &item: this->context.selectable) {
this->scene.removeItem(item);
delete item;
}
this->context.selectable.clear();
} }
void Schema::showConnectable(Pin *domainPin) { void Schema::showConnectable(Pin *domainPin) {
@ -236,7 +231,7 @@ namespace display {
continue; continue;
} }
auto rect = new QGraphicsRectItem(group->boundingRect()); auto rect = new QGraphicsRectItem(group->boundingRect());
rect->setPen(selectedPen); rect->setBrush(selectedBrush);
rect->setPos(group->scenePos()); rect->setPos(group->scenePos());
auto _rect = rect->rect(); auto _rect = rect->rect();
@ -255,6 +250,7 @@ namespace display {
auto pinInstance = domain::ConnectionComponent{connection.componentInstance.value()->name, connection.pin.value().getName()}; auto pinInstance = domain::ConnectionComponent{connection.componentInstance.value()->name, connection.pin.value().getName()};
auto &instance = pins[pinInstance]; auto &instance = pins[pinInstance];
auto rect = new QGraphicsRectItem(instance->boundingRect()); auto rect = new QGraphicsRectItem(instance->boundingRect());
rect->setBrush(selectedBrush);
rect->setPen(selectedPen); rect->setPen(selectedPen);
rect->setPos(instance->scenePos()); rect->setPos(instance->scenePos());
@ -276,13 +272,13 @@ namespace display {
domain::InstanceAttribute attribute(attr.getName(), attr.getDefault(), attr); domain::InstanceAttribute attribute(attr.getName(), attr.getDefault(), attr);
if(attr.getPopup().has_value() && attr.getPopup()->getType() == domain::Popup::AUTOMATIC) { if(attr.getPopup().has_value() && attr.getPopup()->getType() == domain::Popup::AUTOMATIC) {
if(attr.getDefault().isType(domain::Value::MEMORY_REFERENCE)) { 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(dialog->exec() == QDialog::Rejected) {
// if any dialog isn't set, whole creation is rejected // if any dialog isn't set, whole creation is rejected
return {}; return {};
} }
} else { } else {
auto dialog = new AttributeDialog(&attribute); auto dialog = new AttributeDialog(&attribute, false);
if(dialog->exec() == QDialog::Rejected) { if(dialog->exec() == QDialog::Rejected) {
// if any dialog isn't set, whole creation is rejected // if any dialog isn't set, whole creation is rejected
return {}; return {};
@ -301,7 +297,7 @@ namespace display {
instanceAttributes.emplace_back(attr.getName(), attr.getDefault(), attr); 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->exec() == QDialog::Rejected) {
// if dialog is rejected, whole creation is rejected // if dialog is rejected, whole creation is rejected
return {}; 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 } // namespace display

View File

@ -4,6 +4,7 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QWidget> #include <QWidget>
#include <QColor>
#include <QGraphicsLineItem> #include <QGraphicsLineItem>
#include <comdel/domain/schema.h> #include <comdel/domain/schema.h>
@ -19,8 +20,9 @@ namespace display {
public: public:
QBrush selectedBrush; QBrush selectedBrush = QBrush(QColor::fromRgb(50, 50, 150, 100), Qt::BrushStyle::SolidPattern);
QPen selectedPen; QPen selectedPen = QPen(QColor::fromRgb(50, 50, 150), 1, Qt::PenStyle::SolidLine);
QPen activeLinePen = QPen(QColor::fromRgb(250, 100, 100));
enum State { enum State {
DEFAULT, DEFAULT,
@ -68,15 +70,11 @@ namespace display {
domain::Schema *schema{}; domain::Schema *schema{};
std::optional<domain::Library> library; std::optional<domain::Library> library;
std::vector<domain::BusInstance *>
getAvailableConnectionBusses(domain::ComponentInstance *instance, domain::Pin &pin);
std::vector<domain::ConnectionComponent>
getAvailableConnectionPins(domain::ComponentInstance *instance, domain::Pin &pin);
std::vector<domain::InstanceAttribute> populateAttributes(std::vector<domain::Attribute>& attributes); std::vector<domain::InstanceAttribute> populateAttributes(std::vector<domain::Attribute>& attributes);
std::vector<domain::InstanceAttribute> populateSingleAutomaticConnection(domain::Connection connection); std::vector<domain::InstanceAttribute> populateSingleAutomaticConnection(domain::Connection connection);
void clearSelectable();
}; };
} // namespace display } // namespace display

View File

@ -9,9 +9,9 @@
#include <QPushButton> #include <QPushButton>
namespace display { namespace display {
SingleAutomaticDialog::SingleAutomaticDialog(std::vector<domain::InstanceAttribute> &values): attributes(values) { SingleAutomaticDialog::SingleAutomaticDialog(std::vector<domain::InstanceAttribute> &values, bool updating): attributes(values) {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(QString::fromStdString("Postavi poveznicu")); setWindowTitle(QString::fromStdString(updating ? "Ažuriraj poveznicu" : "Postavi poveznicu"));
firstValue = values[0].value; firstValue = values[0].value;
secondValue = values[1].value; secondValue = values[1].value;
@ -29,7 +29,7 @@ namespace display {
setupValues(firstLayout, values[0], &SingleAutomaticDialog::onFirstEnumerationChanged); setupValues(firstLayout, values[0], &SingleAutomaticDialog::onFirstEnumerationChanged);
setupValues(secondLayout, values[1], &SingleAutomaticDialog::onSecondEnumerationChanged); 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); connect(button, &QPushButton::clicked, this, &SingleAutomaticDialog::onUpdate);
parentLayout->addWidget(button); parentLayout->addWidget(button);
} }

View File

@ -19,7 +19,7 @@ namespace display {
std::vector<domain::InstanceAttribute> &attributes; std::vector<domain::InstanceAttribute> &attributes;
public: public:
explicit SingleAutomaticDialog(std::vector<domain::InstanceAttribute>& values); explicit SingleAutomaticDialog(std::vector<domain::InstanceAttribute>& values, bool updating = true);
void setupValues(QVBoxLayout *layout, domain::InstanceAttribute &attribute, void (display::SingleAutomaticDialog::* handler)(int)); void setupValues(QVBoxLayout *layout, domain::InstanceAttribute &attribute, void (display::SingleAutomaticDialog::* handler)(int));

View File

@ -172,7 +172,7 @@ namespace domain {
if(memoryReference != nullopt) { if(memoryReference != nullopt) {
if(memoryInstances.count(*memoryReference) == 0) { if(memoryInstances.count(*memoryReference) == 0) {
context.attributes["memoryReference"] = domain::Value::fromString(memoryReference.value()); 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); errors.emplace_back(component.get(), nullptr, Action::ERROR, message);
} }
} }

View File

@ -1,7 +1,13 @@
#include "display.h" #include "display.h"
#include <QBrush>
#include <QPen>
namespace domain { namespace domain {
QBrush busBrush(QColor::fromRgb(200, 200, 200));
QPen busPen(QColor::fromRgb(200, 200, 200));
Display::Display(std::vector<ui::Item> items) : items(items) {} Display::Display(std::vector<ui::Item> items) : items(items) {}
void Display::render(QGraphicsItemGroup *group) { void Display::render(QGraphicsItemGroup *group) {
@ -39,11 +45,16 @@ namespace domain {
} }
void ui::Bus::render(QGraphicsItemGroup *group, int size) { void ui::Bus::render(QGraphicsItemGroup *group, int size) {
int _w = w, _h = h;
if (orientation == HORIZONTAL) { if (orientation == HORIZONTAL) {
group->addToGroup(new QGraphicsRectItem(x, y, size, h)); _w = size;
} else { } 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() { int ui::Bus::getDefaultSize() {

View File

@ -1,4 +1,4 @@
#include "comdellexer.h" #include "comdel_lexer.h"
#include "token.h" #include "token.h"
#include "tokens_type.h" #include "tokens_type.h"

View File

@ -1,4 +1,4 @@
#include "comdellexer.h" #include "comdel_lexer.h"
#include "comdel_parser.h" #include "comdel_parser.h"
#include "parser_util.h" #include "parser_util.h"

View File

@ -1,6 +1,5 @@
// Version 0.0.1 // Version 0.0.1
#include "libraries\frisc\vjezba1\FRISC.cdl" #include "libraries\frisc\vjezba1\FRISC.cdl"
#include "libraries\frisc\vjezba1\dma.cdl"
#include "libraries\frisc\vjezba1\memory.cdl" #include "libraries\frisc\vjezba1\memory.cdl"
@ -24,43 +23,31 @@ component System
wire --BACK; wire --BACK;
//PIOSabirnica
wire<8> PIO_DATA;
wire READY;
wire STROBE;
//directRam //directRam
wire INT; wire INT;
// components -------------------------------------------- // components --------------------------------------------
subcomponent Memorija memorija<false, 1, 1024, 8, 0>(ADR, DATA, READ, WRITE, SIZE, WAIT, INT, *, *, *); subcomponent Memorija memorija<false, 1, 65536, 8, 0>(ADR, DATA, READ, WRITE, SIZE, WAIT, *, *, *, INT);
subcomponent FRISC procesor(ADR, DATA, READ, WRITE, SIZE, WAIT, INT0, INT1, INT2, INT3, --IACK, 1, *, 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 { display {
component { x: -104; y: -102; ref: "procesor"; } component { x: -377; y: -302; ref: "procesor"; }
component { x: 39; y: 199; ref: "memorija"; } component { x: -56; y: -80; ref: "memorija"; }
component { x: -352; y: 13; ref: "dma"; }
// glavnaSabirnica bus // glavnaSabirnica bus
rectangle { rectangle {
x: -106; y: 80; x: -377; y: -106;
w: 100; h: 20; w: 100; h: 20;
} }
// PIOSabirnica bus
// directRam bus // directRam bus
line {x1:-54; y1:14; x2:-55; y2:90;} line {x1:-6; y1:-96; x2:-326; y2:-95;}
line {x1:89; y1:183; x2:-55; y2:90;} line {x1:-327; y1:-186; x2:-326; y2:-95;}
line {x1:-244; y1:79; x2:-55; y2:90;} line {x1:-72; y1:-52; x2:-261; y2:-252;}
line {x1:23; y1:227; x2:12; y2:-52;}
} }
} }

View File

@ -2,35 +2,15 @@
@schema { @schema {
@instance procesor FRISC { @instance procesor FRISC {
@position (-162, -117) @position (-543, -304)
@attribute _memory null @attribute _memory null
} }
@instance dma DMA {
@position (-393, -26)
@attribute pocetnaAdresa 0
}
@instance glavnaSabirnica glavnaSabirnica { @instance glavnaSabirnica glavnaSabirnica {
@position (-155, 49) @position (-544, -91)
@size 100 @size 100
} }
@instance PIOSabirnica PIOSabirnica { @connection (procesor.glavniPin, glavnaSabirnica) {
@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) {
} }
} }

View File

@ -32,11 +32,13 @@ void MainWindow::setupUi()
ui->centralwidget->setLayout(layout); ui->centralwidget->setLayout(layout);
// setup toolbar // setup toolbar
ui->toolBar->addAction("Load library", this, &MainWindow::onLoadLibrary); ui->toolBar->addAction("Učitaj bibiloteku", this, &MainWindow::onLoadLibrary);
ui->toolBar->addAction("Load schema", this, &MainWindow::onLoadSchema); ui->toolBar->addAction("Učitaj shemu", this, &MainWindow::onLoadSchema);
ui->toolBar->addAction("Save schema", this, &MainWindow::onStoreScheme); ui->toolBar->addAction("Spremi shemu", this, &MainWindow::onStoreScheme);
ui->toolBar->addAction("Generate system", this, &MainWindow::onGenerateComdel); 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); connect(ui->actionValidate, &QAction::triggered, this, &MainWindow::onValidateSchema);
// setup central content // setup central content
@ -47,10 +49,10 @@ void MainWindow::setupUi()
schemaParent->setLayout(schemaLayout); schemaParent->setLayout(schemaLayout);
schemaDisplay = new display::Schema(); schemaDisplay = new display::Schema();
schemaLayout->setMargin(0); schemaLayout->setContentsMargins(0, 0, 0, 0);
schemaLayout->addWidget(schemaDisplay, 1); schemaLayout->addWidget(schemaDisplay, 1);
layout->setMargin(0); layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(libraryDisplay); layout->addWidget(libraryDisplay);
layout->addWidget(schemaParent, 1); layout->addWidget(schemaParent, 1);
@ -62,7 +64,7 @@ void MainWindow::setupUi()
void MainWindow::onLoadLibrary() { void MainWindow::onLoadLibrary() {
auto filename = QFileDialog::getOpenFileName(this, auto filename = QFileDialog::getOpenFileName(this,
tr("Open library"), "/home", tr("Comdel library (*.csl)")); tr("Otvori biblioteku"), "", tr("Comdel biblioteka (*.csl)"));
if(!filename.isEmpty()) { if(!filename.isEmpty()) {
std::ostringstream output; std::ostringstream output;
log->clear(); log->clear();
@ -81,7 +83,7 @@ void MainWindow::onLoadLibrary() {
void MainWindow::onLoadSchema() { void MainWindow::onLoadSchema() {
auto filename = QFileDialog::getOpenFileName(this, auto filename = QFileDialog::getOpenFileName(this,
tr("Open schema"), "/home", tr("Comdel schema (*.csl)")); tr("Otvori shemu"), "", tr("Comdel shema (*.csl)"));
if(!filename.isEmpty()) { if(!filename.isEmpty()) {
std::ostringstream output; std::ostringstream output;
log->clear(); log->clear();
@ -102,7 +104,7 @@ void MainWindow::onLoadSchema() {
void MainWindow::onStoreScheme() { void MainWindow::onStoreScheme() {
auto filename = QFileDialog::getSaveFileName(this, auto filename = QFileDialog::getSaveFileName(this,
tr("Save schema"), "/home", tr("Comdel schema (*.csl)")); tr("Spremi shemu"), "", tr("Comdel shema (*.csl)"));
if(!filename.isEmpty()) { if(!filename.isEmpty()) {
log->clear(); log->clear();
@ -113,9 +115,9 @@ void MainWindow::onStoreScheme() {
out<<output.str(); out<<output.str();
out.close(); out.close();
log->appendPlainText("Successfully stored schema\n"); log->appendPlainText("Uspješno spremljena shema\n");
} else { } 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() { void MainWindow::onGenerateComdel() {
auto filename = QFileDialog::getSaveFileName(this, auto filename = QFileDialog::getSaveFileName(this,
tr("Save schema"), "/home", tr("Comdel system (*.system)")); tr("Spremi shemu"), "", tr("Comdel sustav (*.system)"));
if(!filename.isEmpty()) { if(!filename.isEmpty()) {
log->clear(); log->clear();
@ -140,9 +142,9 @@ void MainWindow::onGenerateComdel() {
out<<output.str(); out<<output.str();
out.close(); out.close();
log->appendPlainText("Successfully generated comdel\n"); log->appendPlainText("Uspješno generiranje comdel modela\n");
} else { } else {
log->appendPlainText("Failed generating comdel\n"); log->appendPlainText("Neuspješno generiranje comdel modela\n");
} }
} }
} }

View File

@ -53,17 +53,17 @@
</widget> </widget>
<action name="actionSave_schema"> <action name="actionSave_schema">
<property name="text"> <property name="text">
<string>Save schema</string> <string>Spremi shemu</string>
</property> </property>
</action> </action>
<action name="actionExport_schema"> <action name="actionExport_schema">
<property name="text"> <property name="text">
<string>Export schema</string> <string>Generiraj comdel</string>
</property> </property>
</action> </action>
<action name="actionValidate"> <action name="actionValidate">
<property name="text"> <property name="text">
<string>Validate</string> <string>Validairaj</string>
</property> </property>
</action> </action>
</widget> </widget>