From 9c03909ebaec8157824a9cb13eeea774d29b35e1 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 13:41:16 +0200 Subject: Make arch specific main window --- gui/CMakeLists.txt | 3 +- gui/basewindow.cc | 138 +++++++++++++++++++++++++++++++++++++++++++++ gui/basewindow.h | 45 +++++++++++++++ gui/dummy/mainwindow.cc | 19 +++++++ gui/dummy/mainwindow.h | 21 +++++++ gui/emb.cc | 138 --------------------------------------------- gui/emb.h | 20 ------- gui/fpgaviewwidget.cc | 4 +- gui/ice40/mainwindow.cc | 29 ++++++++++ gui/ice40/mainwindow.h | 21 +++++++ gui/mainwindow.cc | 145 ------------------------------------------------ gui/mainwindow.h | 36 ------------ 12 files changed, 277 insertions(+), 342 deletions(-) create mode 100644 gui/basewindow.cc create mode 100644 gui/basewindow.h create mode 100644 gui/dummy/mainwindow.cc create mode 100644 gui/dummy/mainwindow.h delete mode 100644 gui/emb.cc delete mode 100644 gui/emb.h create mode 100644 gui/ice40/mainwindow.cc create mode 100644 gui/ice40/mainwindow.h delete mode 100644 gui/mainwindow.cc delete mode 100644 gui/mainwindow.h (limited to 'gui') diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 5db86a9b..b4dcde11 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -2,6 +2,7 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) aux_source_directory(. GUI_SOURCE_FILES) +aux_source_directory(${family}/ GUI_SOURCE_FILES) set(_RESOURCES nextpnr.qrc) qt5_add_resources(GUI_RESOURCE_FILES ${_RESOURCES}) @@ -10,6 +11,6 @@ set(GUI_LIBRARY_FILES_${ufamily} Qt5::Widgets Qt5::OpenGL ${OPENGL_LIBRARIES} Qt add_library(gui_${family} STATIC ${GUI_SOURCE_FILES} ${GUI_RESOURCE_FILES}) -target_include_directories(gui_${family} PRIVATE ../${family}/) +target_include_directories(gui_${family} PRIVATE ../${family} ${family} ../3rdparty/QtPropertyBrowser/src) target_compile_definitions(gui_${family} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family} QT_NO_KEYWORDS) target_link_libraries(gui_${family} Qt5::Widgets) diff --git a/gui/basewindow.cc b/gui/basewindow.cc new file mode 100644 index 00000000..cbf0faae --- /dev/null +++ b/gui/basewindow.cc @@ -0,0 +1,138 @@ +#include "mainwindow.h" +#include +#include +#include +#include +#include +#include +#include "designwidget.h" +#include "fpgaviewwidget.h" +#include "jsonparse.h" +#include "log.h" +#include "pythontab.h" +//#include "pack.h" +//#include "pcf.h" +#include "place_sa.h" +#include "route.h" +//#include "bitstream.h" +#include "design_utils.h" + +BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) + : QMainWindow(parent), ctx(_ctx) +{ + Q_INIT_RESOURCE(nextpnr); + + log_files.clear(); + log_streams.clear(); + log_write_function = [this](std::string text) { info->info(text); }; + + setObjectName(QStringLiteral("BaseMainWindow")); + resize(1024, 768); + + createMenusAndBars(); + + QWidget *centralWidget = new QWidget(this); + + QGridLayout *gridLayout = new QGridLayout(centralWidget); + gridLayout->setSpacing(6); + gridLayout->setContentsMargins(11, 11, 11, 11); + + QSplitter *splitter_h = new QSplitter(Qt::Horizontal, centralWidget); + QSplitter *splitter_v = new QSplitter(Qt::Vertical, splitter_h); + splitter_h->addWidget(splitter_v); + + gridLayout->addWidget(splitter_h, 0, 0, 1, 1); + + setCentralWidget(centralWidget); + + DesignWidget *designview = new DesignWidget(ctx); + designview->setMinimumWidth(300); + designview->setMaximumWidth(300); + splitter_h->addWidget(designview); + + connect(designview, SIGNAL(info(std::string)), this, + SLOT(writeInfo(std::string))); + + tabWidget = new QTabWidget(); + tabWidget->addTab(new PythonTab(), "Python"); + info = new InfoTab(); + tabWidget->addTab(info, "Info"); + splitter_v->addWidget(new FPGAViewWidget()); + splitter_v->addWidget(tabWidget); +} + +BaseMainWindow::~BaseMainWindow() {} + +void BaseMainWindow::writeInfo(std::string text) { info->info(text); } + +void BaseMainWindow::createMenusAndBars() +{ + QAction *actionOpen = new QAction("Open", this); + QIcon icon1; + icon1.addFile(QStringLiteral(":/icons/resources/open.png")); + actionOpen->setIcon(icon1); + actionOpen->setShortcuts(QKeySequence::Open); + actionOpen->setStatusTip("Open an existing JSON file"); + connect(actionOpen, SIGNAL(triggered()), this, SLOT(open())); + + QAction *actionSave = new QAction("Save", this); + QIcon icon2; + icon2.addFile(QStringLiteral(":/icons/resources/save.png")); + actionSave->setIcon(icon2); + actionSave->setShortcuts(QKeySequence::Save); + actionSave->setStatusTip("Save the ASC to disk"); + connect(actionSave, SIGNAL(triggered()), this, SLOT(save())); + actionSave->setEnabled(false); + + QAction *actionExit = new QAction("Exit", this); + QIcon icon3; + icon3.addFile(QStringLiteral(":/icons/resources/exit.png")); + actionExit->setIcon(icon3); + actionExit->setShortcuts(QKeySequence::Quit); + actionExit->setStatusTip("Exit the application"); + connect(actionExit, SIGNAL(triggered()), this, SLOT(close())); + + QAction *actionAbout = new QAction("About", this); + + menuBar = new QMenuBar(); + menuBar->setGeometry(QRect(0, 0, 1024, 27)); + QMenu *menu_File = new QMenu("&File", menuBar); + QMenu *menu_Help = new QMenu("&Help", menuBar); + menuBar->addAction(menu_File->menuAction()); + menuBar->addAction(menu_Help->menuAction()); + setMenuBar(menuBar); + + mainToolBar = new QToolBar(); + addToolBar(Qt::TopToolBarArea, mainToolBar); + + statusBar = new QStatusBar(); + setStatusBar(statusBar); + + menu_File->addAction(actionOpen); + menu_File->addAction(actionSave); + menu_File->addSeparator(); + menu_File->addAction(actionExit); + menu_Help->addAction(actionAbout); + + mainToolBar->addAction(actionOpen); + mainToolBar->addAction(actionSave); +} + +void BaseMainWindow::open() +{ + QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), + QString("*.json")); + if (!fileName.isEmpty()) { + tabWidget->setCurrentWidget(info); + + std::string fn = fileName.toStdString(); + std::istream *f = new std::ifstream(fn); + + parse_json_file(f, fn, ctx); + + // pack_design(ctx); + print_utilisation(ctx); + } +} + +bool BaseMainWindow::save() { return false; } diff --git a/gui/basewindow.h b/gui/basewindow.h new file mode 100644 index 00000000..52efd6b1 --- /dev/null +++ b/gui/basewindow.h @@ -0,0 +1,45 @@ +#ifndef BASEMAINWINDOW_H +#define BASEMAINWINDOW_H + +#include "infotab.h" +#include "nextpnr.h" + +#include +#include +#include +#include +#include +#include + + +// FIXME +USING_NEXTPNR_NAMESPACE + +class BaseMainWindow : public QMainWindow +{ + Q_OBJECT + + public: + explicit BaseMainWindow(Context *ctx, QWidget *parent = 0); + ~BaseMainWindow(); + Context *getContext() { return ctx; } + + protected: + void createMenusAndBars(); + + protected Q_SLOTS: + void writeInfo(std::string text); + void open(); + bool save(); + + protected: + Context *ctx; + QTabWidget *tabWidget; + InfoTab *info; + + QMenuBar *menuBar; + QToolBar *mainToolBar; + QStatusBar *statusBar; +}; + +#endif // BASEMAINWINDOW_H diff --git a/gui/dummy/mainwindow.cc b/gui/dummy/mainwindow.cc new file mode 100644 index 00000000..dad73d7e --- /dev/null +++ b/gui/dummy/mainwindow.cc @@ -0,0 +1,19 @@ +#include "mainwindow.h" + +MainWindow::MainWindow(Context *_ctx, QWidget *parent) + : BaseMainWindow(_ctx, parent) +{ + std::string title = "nextpnr-dummy - " + ctx->getChipName(); + setWindowTitle(title.c_str()); + + createMenu(); +} + +MainWindow::~MainWindow() {} + +void MainWindow::createMenu() +{ + QMenu *menu_Custom = new QMenu("&Dummy", menuBar); + menuBar->addAction(menu_Custom->menuAction()); + +} diff --git a/gui/dummy/mainwindow.h b/gui/dummy/mainwindow.h new file mode 100644 index 00000000..e9c8ff77 --- /dev/null +++ b/gui/dummy/mainwindow.h @@ -0,0 +1,21 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include "../basewindow.h" + +// FIXME +USING_NEXTPNR_NAMESPACE + +class MainWindow : public BaseMainWindow +{ + Q_OBJECT + + public: + explicit MainWindow(Context *ctx, QWidget *parent = 0); + ~MainWindow(); + + public: + void createMenu(); +}; + +#endif // MAINWINDOW_H diff --git a/gui/emb.cc b/gui/emb.cc deleted file mode 100644 index 2e3379d5..00000000 --- a/gui/emb.cc +++ /dev/null @@ -1,138 +0,0 @@ -// -// Copyright (C) 2011 Mateusz Loskot -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Blog article: http://mateusz.loskot.net/?p=2819 - -#include "emb.h" -#include -#include -#include -#include - -namespace emb { -struct Stdout -{ - PyObject_HEAD stdout_write_type write; -}; - -PyObject *Stdout_write(PyObject *self, PyObject *args) -{ - std::size_t written(0); - Stdout *selfimpl = reinterpret_cast(self); - if (selfimpl->write) { - char *data; - if (!PyArg_ParseTuple(args, "s", &data)) - return 0; - - std::string str(data); - selfimpl->write(str); - written = str.size(); - } - return PyLong_FromSize_t(written); -} - -PyObject *Stdout_flush(PyObject *self, PyObject *args) -{ - // no-op - return Py_BuildValue(""); -} - -PyMethodDef Stdout_methods[] = { - {"write", Stdout_write, METH_VARARGS, "sys.stdout.write"}, - {"flush", Stdout_flush, METH_VARARGS, "sys.stdout.write"}, - {0, 0, 0, 0} // sentinel -}; - -PyTypeObject StdoutType = { - PyVarObject_HEAD_INIT(0, 0) "emb.StdoutType", /* tp_name */ - sizeof(Stdout), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "emb.Stdout objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - Stdout_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ -}; - -PyModuleDef embmodule = { - PyModuleDef_HEAD_INIT, "emb", 0, -1, 0, -}; - -// Internal state -PyObject *g_stdout; -PyObject *g_stdout_saved; - -PyMODINIT_FUNC PyInit_emb(void) -{ - g_stdout = 0; - g_stdout_saved = 0; - - StdoutType.tp_new = PyType_GenericNew; - if (PyType_Ready(&StdoutType) < 0) - return 0; - - PyObject *m = PyModule_Create(&embmodule); - if (m) { - Py_INCREF(&StdoutType); - PyModule_AddObject(m, "Stdout", - reinterpret_cast(&StdoutType)); - } - return m; -} - -void set_stdout(stdout_write_type write) -{ - if (!g_stdout) { - g_stdout_saved = PySys_GetObject("stdout"); // borrowed - g_stdout = StdoutType.tp_new(&StdoutType, 0, 0); - } - - Stdout *impl = reinterpret_cast(g_stdout); - impl->write = write; - PySys_SetObject("stdout", g_stdout); -} - -void reset_stdout() -{ - if (g_stdout_saved) - PySys_SetObject("stdout", g_stdout_saved); - - Py_XDECREF(g_stdout); - g_stdout = 0; -} - -void append_inittab() { PyImport_AppendInittab("emb", emb::PyInit_emb); } - -} // namespace emb diff --git a/gui/emb.h b/gui/emb.h deleted file mode 100644 index 3daa7ca3..00000000 --- a/gui/emb.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Copyright (C) 2011 Mateusz Loskot -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Blog article: http://mateusz.loskot.net/?p=2819 - -#include -#include -#include - -namespace emb { -typedef std::function stdout_write_type; - -void set_stdout(stdout_write_type write); -void reset_stdout(); - -void append_inittab(); -} // namespace emb diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 000b4cf0..6b7e7787 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -9,14 +9,14 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), m_xMove(0), m_yMove(0), m_zDistance(1.0) { - ctx = qobject_cast(getMainWindow())->getContext(); + ctx = qobject_cast(getMainWindow())->getContext(); } QMainWindow *FPGAViewWidget::getMainWindow() { QWidgetList widgets = qApp->topLevelWidgets(); for (QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i) - if ((*i)->objectName() == "MainWindow") + if ((*i)->objectName() == "BaseMainWindow") return (QMainWindow *)(*i); return NULL; } diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc new file mode 100644 index 00000000..4f53c551 --- /dev/null +++ b/gui/ice40/mainwindow.cc @@ -0,0 +1,29 @@ +#include "mainwindow.h" +#include +#include +#include "jsonparse.h" +#include "log.h" +#include "pack.h" +#include "pcf.h" +#include "place_sa.h" +#include "route.h" +#include "bitstream.h" +#include "design_utils.h" + +MainWindow::MainWindow(Context *_ctx, QWidget *parent) + : BaseMainWindow(_ctx, parent) +{ + std::string title = "nextpnr-ice40 - " + ctx->getChipName(); + setWindowTitle(title.c_str()); + + createMenu(); +} + +MainWindow::~MainWindow() {} + +void MainWindow::createMenu() +{ + QMenu *menu_Custom = new QMenu("&ICE 40", menuBar); + menuBar->addAction(menu_Custom->menuAction()); + +} diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h new file mode 100644 index 00000000..e9c8ff77 --- /dev/null +++ b/gui/ice40/mainwindow.h @@ -0,0 +1,21 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include "../basewindow.h" + +// FIXME +USING_NEXTPNR_NAMESPACE + +class MainWindow : public BaseMainWindow +{ + Q_OBJECT + + public: + explicit MainWindow(Context *ctx, QWidget *parent = 0); + ~MainWindow(); + + public: + void createMenu(); +}; + +#endif // MAINWINDOW_H diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc deleted file mode 100644 index 91232390..00000000 --- a/gui/mainwindow.cc +++ /dev/null @@ -1,145 +0,0 @@ -#include "mainwindow.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "designwidget.h" -#include "fpgaviewwidget.h" -#include "jsonparse.h" -#include "log.h" -#include "pythontab.h" -//#include "pack.h" -//#include "pcf.h" -#include "place_sa.h" -#include "pybindings.h" -#include "route.h" -//#include "bitstream.h" -#include "design_utils.h" - -MainWindow::MainWindow(Context *_ctx, QWidget *parent) - : QMainWindow(parent), ctx(_ctx) -{ - Q_INIT_RESOURCE(nextpnr); - - log_files.clear(); - log_streams.clear(); - log_write_function = [this](std::string text) { info->info(text); }; - - std::string title = "nextpnr-ice40 - " + ctx->getChipName(); - setWindowTitle(title.c_str()); - setObjectName(QStringLiteral("MainWindow")); - resize(1024, 768); - - createMenusAndBars(); - - QWidget *centralWidget = new QWidget(this); - - QGridLayout *gridLayout = new QGridLayout(centralWidget); - gridLayout->setSpacing(6); - gridLayout->setContentsMargins(11, 11, 11, 11); - - QSplitter *splitter_h = new QSplitter(Qt::Horizontal, centralWidget); - QSplitter *splitter_v = new QSplitter(Qt::Vertical, splitter_h); - splitter_h->addWidget(splitter_v); - - gridLayout->addWidget(splitter_h, 0, 0, 1, 1); - - setCentralWidget(centralWidget); - - DesignWidget *designview = new DesignWidget(ctx); - designview->setMinimumWidth(300); - designview->setMaximumWidth(300); - splitter_h->addWidget(designview); - - connect(designview, SIGNAL(info(std::string)), this, - SLOT(writeInfo(std::string))); - - tabWidget = new QTabWidget(); - tabWidget->addTab(new PythonTab(), "Python"); - info = new InfoTab(); - tabWidget->addTab(info, "Info"); - splitter_v->addWidget(new FPGAViewWidget()); - splitter_v->addWidget(tabWidget); -} - -MainWindow::~MainWindow() {} - -void MainWindow::writeInfo(std::string text) { info->info(text); } - -void MainWindow::createMenusAndBars() -{ - QAction *actionOpen = new QAction("Open", this); - QIcon icon1; - icon1.addFile(QStringLiteral(":/icons/resources/open.png")); - actionOpen->setIcon(icon1); - actionOpen->setShortcuts(QKeySequence::Open); - actionOpen->setStatusTip("Open an existing JSON file"); - connect(actionOpen, SIGNAL(triggered()), this, SLOT(open())); - - QAction *actionSave = new QAction("Save", this); - QIcon icon2; - icon2.addFile(QStringLiteral(":/icons/resources/save.png")); - actionSave->setIcon(icon2); - actionSave->setShortcuts(QKeySequence::Save); - actionSave->setStatusTip("Save the ASC to disk"); - connect(actionSave, SIGNAL(triggered()), this, SLOT(save())); - actionSave->setEnabled(false); - - QAction *actionExit = new QAction("Exit", this); - QIcon icon3; - icon3.addFile(QStringLiteral(":/icons/resources/exit.png")); - actionExit->setIcon(icon3); - actionExit->setShortcuts(QKeySequence::Quit); - actionExit->setStatusTip("Exit the application"); - connect(actionExit, SIGNAL(triggered()), this, SLOT(close())); - - QAction *actionAbout = new QAction("About", this); - - QMenuBar *menuBar = new QMenuBar(); - menuBar->setGeometry(QRect(0, 0, 1024, 27)); - QMenu *menu_File = new QMenu("&File", menuBar); - QMenu *menu_Help = new QMenu("&Help", menuBar); - menuBar->addAction(menu_File->menuAction()); - menuBar->addAction(menu_Help->menuAction()); - setMenuBar(menuBar); - - QToolBar *mainToolBar = new QToolBar(); - addToolBar(Qt::TopToolBarArea, mainToolBar); - - QStatusBar *statusBar = new QStatusBar(); - setStatusBar(statusBar); - - menu_File->addAction(actionOpen); - menu_File->addAction(actionSave); - menu_File->addSeparator(); - menu_File->addAction(actionExit); - menu_Help->addAction(actionAbout); - - mainToolBar->addAction(actionOpen); - mainToolBar->addAction(actionSave); -} - -void MainWindow::open() -{ - QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), - QString("*.json")); - if (!fileName.isEmpty()) { - tabWidget->setCurrentWidget(info); - - std::string fn = fileName.toStdString(); - std::istream *f = new std::ifstream(fn); - - parse_json_file(f, fn, ctx); - - // pack_design(ctx); - print_utilisation(ctx); - } -} - -bool MainWindow::save() { return false; } diff --git a/gui/mainwindow.h b/gui/mainwindow.h deleted file mode 100644 index 35d917d9..00000000 --- a/gui/mainwindow.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include "infotab.h" -#include "nextpnr.h" - -#include -#include - -// FIXME -USING_NEXTPNR_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - - public: - explicit MainWindow(Context *ctx, QWidget *parent = 0); - ~MainWindow(); - Context *getContext() { return ctx; } - - private: - void createMenusAndBars(); - - private Q_SLOTS: - void writeInfo(std::string text); - void open(); - bool save(); - - private: - Context *ctx; - QTabWidget *tabWidget; - InfoTab *info; -}; - -#endif // MAINWINDOW_H -- cgit v1.2.3 From 23fe31da44a2e2596335c09ae983217ffbc8f6b1 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 13:55:36 +0200 Subject: cleanup --- gui/basewindow.cc | 2 +- gui/basewindow.h | 7 +++---- gui/dummy/mainwindow.cc | 1 - gui/ice40/mainwindow.cc | 5 ++--- 4 files changed, 6 insertions(+), 9 deletions(-) (limited to 'gui') diff --git a/gui/basewindow.cc b/gui/basewindow.cc index cbf0faae..fa9528fc 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -1,4 +1,3 @@ -#include "mainwindow.h" #include #include #include @@ -9,6 +8,7 @@ #include "fpgaviewwidget.h" #include "jsonparse.h" #include "log.h" +#include "mainwindow.h" #include "pythontab.h" //#include "pack.h" //#include "pcf.h" diff --git a/gui/basewindow.h b/gui/basewindow.h index 52efd6b1..630e0f84 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -5,12 +5,11 @@ #include "nextpnr.h" #include -#include #include #include -#include #include - +#include +#include // FIXME USING_NEXTPNR_NAMESPACE @@ -36,7 +35,7 @@ class BaseMainWindow : public QMainWindow Context *ctx; QTabWidget *tabWidget; InfoTab *info; - + QMenuBar *menuBar; QToolBar *mainToolBar; QStatusBar *statusBar; diff --git a/gui/dummy/mainwindow.cc b/gui/dummy/mainwindow.cc index dad73d7e..a9420524 100644 --- a/gui/dummy/mainwindow.cc +++ b/gui/dummy/mainwindow.cc @@ -15,5 +15,4 @@ void MainWindow::createMenu() { QMenu *menu_Custom = new QMenu("&Dummy", menuBar); menuBar->addAction(menu_Custom->menuAction()); - } diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index 4f53c551..3744cdc7 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -1,14 +1,14 @@ #include "mainwindow.h" #include #include +#include "bitstream.h" +#include "design_utils.h" #include "jsonparse.h" #include "log.h" #include "pack.h" #include "pcf.h" #include "place_sa.h" #include "route.h" -#include "bitstream.h" -#include "design_utils.h" MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, parent) @@ -25,5 +25,4 @@ void MainWindow::createMenu() { QMenu *menu_Custom = new QMenu("&ICE 40", menuBar); menuBar->addAction(menu_Custom->menuAction()); - } -- cgit v1.2.3 From 2d405f966b4e69b95cd4ea9acbb5438e1fa91e69 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 14:12:02 +0200 Subject: Add graphics view in tab --- gui/basewindow.cc | 6 +++++- gui/basewindow.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/basewindow.cc b/gui/basewindow.cc index fa9528fc..25603322 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -57,7 +57,11 @@ BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) tabWidget->addTab(new PythonTab(), "Python"); info = new InfoTab(); tabWidget->addTab(info, "Info"); - splitter_v->addWidget(new FPGAViewWidget()); + + centralTabWidget = new QTabWidget(); + centralTabWidget->addTab(new FPGAViewWidget(), "Graphics"); + + splitter_v->addWidget(centralTabWidget); splitter_v->addWidget(tabWidget); } diff --git a/gui/basewindow.h b/gui/basewindow.h index 630e0f84..1d0ac468 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -34,6 +34,7 @@ class BaseMainWindow : public QMainWindow protected: Context *ctx; QTabWidget *tabWidget; + QTabWidget *centralTabWidget; InfoTab *info; QMenuBar *menuBar; -- cgit v1.2.3 From 097df1869d654b1214b925fe991aa09d2ef5b3cd Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 15:41:40 +0200 Subject: Added task manager and worker thread for ice40 --- gui/basewindow.cc | 29 ++----------------------- gui/basewindow.h | 9 +++++--- gui/dummy/mainwindow.cc | 9 ++++++++ gui/dummy/mainwindow.h | 6 ++++- gui/ice40/mainwindow.cc | 21 ++++++++++++++++++ gui/ice40/mainwindow.h | 10 ++++++++- gui/ice40/worker.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ gui/ice40/worker.h | 37 +++++++++++++++++++++++++++++++ 8 files changed, 147 insertions(+), 32 deletions(-) create mode 100644 gui/ice40/worker.cc create mode 100644 gui/ice40/worker.h (limited to 'gui') diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 25603322..1e6b171f 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -3,28 +3,22 @@ #include #include #include -#include #include "designwidget.h" #include "fpgaviewwidget.h" #include "jsonparse.h" #include "log.h" #include "mainwindow.h" #include "pythontab.h" -//#include "pack.h" -//#include "pcf.h" -#include "place_sa.h" -#include "route.h" -//#include "bitstream.h" -#include "design_utils.h" + BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) : QMainWindow(parent), ctx(_ctx) { Q_INIT_RESOURCE(nextpnr); + qRegisterMetaType(); log_files.clear(); log_streams.clear(); - log_write_function = [this](std::string text) { info->info(text); }; setObjectName(QStringLiteral("BaseMainWindow")); resize(1024, 768); @@ -121,22 +115,3 @@ void BaseMainWindow::createMenusAndBars() mainToolBar->addAction(actionOpen); mainToolBar->addAction(actionSave); } - -void BaseMainWindow::open() -{ - QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), - QString("*.json")); - if (!fileName.isEmpty()) { - tabWidget->setCurrentWidget(info); - - std::string fn = fileName.toStdString(); - std::istream *f = new std::ifstream(fn); - - parse_json_file(f, fn, ctx); - - // pack_design(ctx); - print_utilisation(ctx); - } -} - -bool BaseMainWindow::save() { return false; } diff --git a/gui/basewindow.h b/gui/basewindow.h index 1d0ac468..d6915ae9 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -14,13 +14,15 @@ // FIXME USING_NEXTPNR_NAMESPACE +Q_DECLARE_METATYPE(std::string) + class BaseMainWindow : public QMainWindow { Q_OBJECT public: explicit BaseMainWindow(Context *ctx, QWidget *parent = 0); - ~BaseMainWindow(); + virtual ~BaseMainWindow(); Context *getContext() { return ctx; } protected: @@ -28,8 +30,9 @@ class BaseMainWindow : public QMainWindow protected Q_SLOTS: void writeInfo(std::string text); - void open(); - bool save(); + + virtual void open() = 0; + virtual bool save() = 0; protected: Context *ctx; diff --git a/gui/dummy/mainwindow.cc b/gui/dummy/mainwindow.cc index a9420524..f714e30e 100644 --- a/gui/dummy/mainwindow.cc +++ b/gui/dummy/mainwindow.cc @@ -16,3 +16,12 @@ void MainWindow::createMenu() QMenu *menu_Custom = new QMenu("&Dummy", menuBar); menuBar->addAction(menu_Custom->menuAction()); } + +void MainWindow::open() +{ +} + +bool MainWindow::save() +{ + return false; +} \ No newline at end of file diff --git a/gui/dummy/mainwindow.h b/gui/dummy/mainwindow.h index e9c8ff77..ea4480fb 100644 --- a/gui/dummy/mainwindow.h +++ b/gui/dummy/mainwindow.h @@ -12,10 +12,14 @@ class MainWindow : public BaseMainWindow public: explicit MainWindow(Context *ctx, QWidget *parent = 0); - ~MainWindow(); + virtual ~MainWindow(); public: void createMenu(); + + protected Q_SLOTS: + virtual void open(); + virtual bool save(); }; #endif // MAINWINDOW_H diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index 3744cdc7..dafd92e9 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -1,5 +1,6 @@ #include "mainwindow.h" #include +#include #include #include "bitstream.h" #include "design_utils.h" @@ -17,6 +18,10 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent) setWindowTitle(title.c_str()); createMenu(); + + task = new TaskManager(_ctx); + connect(task, SIGNAL(log(std::string)), this, + SLOT(writeInfo(std::string))); } MainWindow::~MainWindow() {} @@ -26,3 +31,19 @@ void MainWindow::createMenu() QMenu *menu_Custom = new QMenu("&ICE 40", menuBar); menuBar->addAction(menu_Custom->menuAction()); } + +void MainWindow::open() +{ + QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), + QString("*.json")); + if (!fileName.isEmpty()) { + tabWidget->setCurrentWidget(info); + + std::string fn = fileName.toStdString(); + task->parsejson(fn); + } +} +bool MainWindow::save() +{ + return false; +} \ No newline at end of file diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h index e9c8ff77..fd65f9ae 100644 --- a/gui/ice40/mainwindow.h +++ b/gui/ice40/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include "../basewindow.h" +#include "worker.h" // FIXME USING_NEXTPNR_NAMESPACE @@ -12,10 +13,17 @@ class MainWindow : public BaseMainWindow public: explicit MainWindow(Context *ctx, QWidget *parent = 0); - ~MainWindow(); + virtual ~MainWindow(); public: void createMenu(); + + protected Q_SLOTS: + virtual void open(); + virtual bool save(); + + private: + TaskManager *task; }; #endif // MAINWINDOW_H diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc new file mode 100644 index 00000000..5a8ff0e9 --- /dev/null +++ b/gui/ice40/worker.cc @@ -0,0 +1,58 @@ +#include "worker.h" +#include +#include "jsonparse.h" +#include "log.h" +#include "pack.h" +#include "pcf.h" +#include "place_sa.h" +#include "route.h" +#include "bitstream.h" +#include "design_utils.h" +#include "timing.h" + +Worker::Worker(Context *_ctx) : ctx(_ctx) +{ + log_write_function = [this](std::string text) { Q_EMIT log(text); }; +} + +void Worker::parsejson(const std::string &filename) +{ + std::string fn = filename; + std::istream *f = new std::ifstream(fn); + + parse_json_file(f, fn, ctx); + if (!pack_design(ctx)) + log_error("Packing design failed.\n"); + double freq = 50e6; + assign_budget(ctx, freq); + print_utilisation(ctx); + + if (!place_design_sa(ctx)) + log_error("Placing design failed.\n"); + if (!route_design(ctx)) + log_error("Routing design failed.\n"); + print_utilisation(ctx); + Q_EMIT log("done"); +} + + +TaskManager::TaskManager(Context *ctx) +{ + Worker *worker = new Worker(ctx); + worker->moveToThread(&workerThread); + connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); + connect(this, &TaskManager::parsejson, worker, &Worker::parsejson); + connect(worker, &Worker::log, this, &TaskManager::info); + workerThread.start(); +} + +TaskManager::~TaskManager() +{ + workerThread.quit(); + workerThread.wait(); +} + +void TaskManager::info(const std::string &result) +{ + Q_EMIT log(result); +} \ No newline at end of file diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h new file mode 100644 index 00000000..5dc25d89 --- /dev/null +++ b/gui/ice40/worker.h @@ -0,0 +1,37 @@ +#ifndef WORKER_H +#define WORKER_H + +#include "nextpnr.h" +#include + +// FIXME +USING_NEXTPNR_NAMESPACE + +class Worker : public QObject +{ + Q_OBJECT +public: + Worker(Context *ctx); +public Q_SLOTS: + void parsejson(const std::string &filename); +Q_SIGNALS: + void log(const std::string &text); +private: + Context *ctx; +}; + +class TaskManager : public QObject +{ + Q_OBJECT + QThread workerThread; +public: + TaskManager(Context *ctx); + ~TaskManager(); +public Q_SLOTS: + void info(const std::string &text); +Q_SIGNALS: + void parsejson(const std::string &); + void log(const std::string &text); +}; + +#endif // WORKER_H -- cgit v1.2.3 From 4fefdbd57c52d6373456bd379e3e54df770e1945 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 21 Jun 2018 16:16:58 +0200 Subject: Cleanup parse_json_file API, some other cleanups Signed-off-by: Clifford Wolf --- gui/ice40/worker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index 5a8ff0e9..bd22f552 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -18,7 +18,7 @@ Worker::Worker(Context *_ctx) : ctx(_ctx) void Worker::parsejson(const std::string &filename) { std::string fn = filename; - std::istream *f = new std::ifstream(fn); + std::ifstream f(fn); parse_json_file(f, fn, ctx); if (!pack_design(ctx)) -- cgit v1.2.3 From 54549d36e911aac8d0b0a2eea6074654c06c9717 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 17:44:18 +0200 Subject: log_error now trows exception, main is covering catch --- gui/basewindow.cc | 1 - gui/basewindow.h | 2 +- gui/dummy/mainwindow.cc | 9 ++------- gui/dummy/mainwindow.h | 2 +- gui/ice40/mainwindow.cc | 8 ++------ gui/ice40/worker.cc | 16 ++++++---------- gui/ice40/worker.h | 18 ++++++++++-------- 7 files changed, 22 insertions(+), 34 deletions(-) (limited to 'gui') diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 1e6b171f..9020a719 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -10,7 +10,6 @@ #include "mainwindow.h" #include "pythontab.h" - BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) : QMainWindow(parent), ctx(_ctx) { diff --git a/gui/basewindow.h b/gui/basewindow.h index d6915ae9..b20d4621 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -30,7 +30,7 @@ class BaseMainWindow : public QMainWindow protected Q_SLOTS: void writeInfo(std::string text); - + virtual void open() = 0; virtual bool save() = 0; diff --git a/gui/dummy/mainwindow.cc b/gui/dummy/mainwindow.cc index f714e30e..7982c5f5 100644 --- a/gui/dummy/mainwindow.cc +++ b/gui/dummy/mainwindow.cc @@ -17,11 +17,6 @@ void MainWindow::createMenu() menuBar->addAction(menu_Custom->menuAction()); } -void MainWindow::open() -{ -} +void MainWindow::open() {} -bool MainWindow::save() -{ - return false; -} \ No newline at end of file +bool MainWindow::save() { return false; } \ No newline at end of file diff --git a/gui/dummy/mainwindow.h b/gui/dummy/mainwindow.h index ea4480fb..c9690f2c 100644 --- a/gui/dummy/mainwindow.h +++ b/gui/dummy/mainwindow.h @@ -19,7 +19,7 @@ class MainWindow : public BaseMainWindow protected Q_SLOTS: virtual void open(); - virtual bool save(); + virtual bool save(); }; #endif // MAINWINDOW_H diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index dafd92e9..934798bb 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -20,8 +20,7 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent) createMenu(); task = new TaskManager(_ctx); - connect(task, SIGNAL(log(std::string)), this, - SLOT(writeInfo(std::string))); + connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string))); } MainWindow::~MainWindow() {} @@ -43,7 +42,4 @@ void MainWindow::open() task->parsejson(fn); } } -bool MainWindow::save() -{ - return false; -} \ No newline at end of file +bool MainWindow::save() { return false; } \ No newline at end of file diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index bd22f552..92a0f6ac 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -1,13 +1,13 @@ #include "worker.h" #include +#include "bitstream.h" +#include "design_utils.h" #include "jsonparse.h" #include "log.h" #include "pack.h" #include "pcf.h" #include "place_sa.h" #include "route.h" -#include "bitstream.h" -#include "design_utils.h" #include "timing.h" Worker::Worker(Context *_ctx) : ctx(_ctx) @@ -15,7 +15,7 @@ Worker::Worker(Context *_ctx) : ctx(_ctx) log_write_function = [this](std::string text) { Q_EMIT log(text); }; } -void Worker::parsejson(const std::string &filename) +void Worker::parsejson(const std::string &filename) { std::string fn = filename; std::ifstream f(fn); @@ -35,8 +35,7 @@ void Worker::parsejson(const std::string &filename) Q_EMIT log("done"); } - -TaskManager::TaskManager(Context *ctx) +TaskManager::TaskManager(Context *ctx) { Worker *worker = new Worker(ctx); worker->moveToThread(&workerThread); @@ -46,13 +45,10 @@ TaskManager::TaskManager(Context *ctx) workerThread.start(); } -TaskManager::~TaskManager() +TaskManager::~TaskManager() { workerThread.quit(); workerThread.wait(); } -void TaskManager::info(const std::string &result) -{ - Q_EMIT log(result); -} \ No newline at end of file +void TaskManager::info(const std::string &result) { Q_EMIT log(result); } \ No newline at end of file diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h index 5dc25d89..12d740dd 100644 --- a/gui/ice40/worker.h +++ b/gui/ice40/worker.h @@ -1,8 +1,8 @@ #ifndef WORKER_H #define WORKER_H -#include "nextpnr.h" #include +#include "nextpnr.h" // FIXME USING_NEXTPNR_NAMESPACE @@ -10,13 +10,14 @@ USING_NEXTPNR_NAMESPACE class Worker : public QObject { Q_OBJECT -public: + public: Worker(Context *ctx); -public Q_SLOTS: + public Q_SLOTS: void parsejson(const std::string &filename); -Q_SIGNALS: + Q_SIGNALS: void log(const std::string &text); -private: + + private: Context *ctx; }; @@ -24,12 +25,13 @@ class TaskManager : public QObject { Q_OBJECT QThread workerThread; -public: + + public: TaskManager(Context *ctx); ~TaskManager(); -public Q_SLOTS: + public Q_SLOTS: void info(const std::string &text); -Q_SIGNALS: + Q_SIGNALS: void parsejson(const std::string &); void log(const std::string &text); }; -- cgit v1.2.3 From 8fac26c2b795865098b1ba16152cd1c510133f29 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 17:56:45 +0200 Subject: Fixed return codes for packer, placer and router --- gui/ice40/worker.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'gui') diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index 92a0f6ac..f86ec55e 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -19,20 +19,22 @@ void Worker::parsejson(const std::string &filename) { std::string fn = filename; std::ifstream f(fn); + try { + parse_json_file(f, fn, ctx); + if (!pack_design(ctx)) + log_error("Packing design failed.\n"); + double freq = 50e6; + assign_budget(ctx, freq); + print_utilisation(ctx); - parse_json_file(f, fn, ctx); - if (!pack_design(ctx)) - log_error("Packing design failed.\n"); - double freq = 50e6; - assign_budget(ctx, freq); - print_utilisation(ctx); - - if (!place_design_sa(ctx)) - log_error("Placing design failed.\n"); - if (!route_design(ctx)) - log_error("Routing design failed.\n"); - print_utilisation(ctx); - Q_EMIT log("done"); + if (!place_design_sa(ctx)) + log_error("Placing design failed.\n"); + if (!route_design(ctx)) + log_error("Routing design failed.\n"); + Q_EMIT log("done"); + } catch (log_execution_error_exception) { + Q_EMIT log("failed"); + } } TaskManager::TaskManager(Context *ctx) -- cgit v1.2.3 From c33a039ac388bfcb5e068a04a7cb1b05ebec7d7f Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 18:08:28 +0200 Subject: Added return code to json parsing and pcf reading --- gui/ice40/worker.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index f86ec55e..5702137b 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -20,7 +20,8 @@ void Worker::parsejson(const std::string &filename) std::string fn = filename; std::ifstream f(fn); try { - parse_json_file(f, fn, ctx); + if (!parse_json_file(f, fn, ctx)) + log_error("Loading design failed.\n"); if (!pack_design(ctx)) log_error("Packing design failed.\n"); double freq = 50e6; @@ -33,7 +34,6 @@ void Worker::parsejson(const std::string &filename) log_error("Routing design failed.\n"); Q_EMIT log("done"); } catch (log_execution_error_exception) { - Q_EMIT log("failed"); } } -- cgit v1.2.3 From 3cd12e3671e5ee108f039cb4350bf885164a8cf5 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 22 Jun 2018 12:11:22 +0200 Subject: Add ability to terminate running tasks --- gui/ice40/mainwindow.cc | 14 ++++++++++---- gui/ice40/worker.cc | 42 ++++++++++++++++++++++++++++++++++++------ gui/ice40/worker.h | 13 ++++++++++++- 3 files changed, 58 insertions(+), 11 deletions(-) (limited to 'gui') diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index 934798bb..e36464a0 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -17,18 +17,24 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent) std::string title = "nextpnr-ice40 - " + ctx->getChipName(); setWindowTitle(title.c_str()); - createMenu(); - task = new TaskManager(_ctx); connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string))); + + createMenu(); } -MainWindow::~MainWindow() {} +MainWindow::~MainWindow() { delete task; } void MainWindow::createMenu() { QMenu *menu_Custom = new QMenu("&ICE 40", menuBar); menuBar->addAction(menu_Custom->menuAction()); + + QAction *actionTerminate = new QAction("Terminate", this); + actionTerminate->setStatusTip("Terminate running task"); + connect(actionTerminate, SIGNAL(triggered()), task, + SLOT(terminate_thread())); + menu_Custom->addAction(actionTerminate); } void MainWindow::open() @@ -39,7 +45,7 @@ void MainWindow::open() tabWidget->setCurrentWidget(info); std::string fn = fileName.toStdString(); - task->parsejson(fn); + Q_EMIT task->parsejson(fn); } } bool MainWindow::save() { return false; } \ No newline at end of file diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index 5702137b..a309f868 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -10,9 +10,19 @@ #include "route.h" #include "timing.h" -Worker::Worker(Context *_ctx) : ctx(_ctx) +struct WorkerInterruptionRequested { - log_write_function = [this](std::string text) { Q_EMIT log(text); }; +}; + +Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx) +{ + log_write_function = [this, parent](std::string text) { + Q_EMIT log(text); + if (parent->shouldTerminate()) { + parent->clearTerminate(); + throw WorkerInterruptionRequested(); + } + }; } void Worker::parsejson(const std::string &filename) @@ -32,14 +42,16 @@ void Worker::parsejson(const std::string &filename) log_error("Placing design failed.\n"); if (!route_design(ctx)) log_error("Routing design failed.\n"); - Q_EMIT log("done"); + Q_EMIT log("DONE\n"); } catch (log_execution_error_exception) { + } catch (WorkerInterruptionRequested) { + Q_EMIT log("CANCELED\n"); } } -TaskManager::TaskManager(Context *ctx) +TaskManager::TaskManager(Context *ctx) : toTerminate(false) { - Worker *worker = new Worker(ctx); + Worker *worker = new Worker(ctx, this); worker->moveToThread(&workerThread); connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); connect(this, &TaskManager::parsejson, worker, &Worker::parsejson); @@ -53,4 +65,22 @@ TaskManager::~TaskManager() workerThread.wait(); } -void TaskManager::info(const std::string &result) { Q_EMIT log(result); } \ No newline at end of file +void TaskManager::info(const std::string &result) { Q_EMIT log(result); } + +void TaskManager::terminate_thread() +{ + QMutexLocker locker(&mutex); + toTerminate = true; +} + +bool TaskManager::shouldTerminate() +{ + QMutexLocker locker(&mutex); + return toTerminate; +} + +void TaskManager::clearTerminate() +{ + QMutexLocker locker(&mutex); + toTerminate = false; +} \ No newline at end of file diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h index 12d740dd..a2d220bd 100644 --- a/gui/ice40/worker.h +++ b/gui/ice40/worker.h @@ -1,17 +1,20 @@ #ifndef WORKER_H #define WORKER_H +#include #include #include "nextpnr.h" // FIXME USING_NEXTPNR_NAMESPACE +class TaskManager; + class Worker : public QObject { Q_OBJECT public: - Worker(Context *ctx); + Worker(Context *ctx, TaskManager *parent); public Q_SLOTS: void parsejson(const std::string &filename); Q_SIGNALS: @@ -29,11 +32,19 @@ class TaskManager : public QObject public: TaskManager(Context *ctx); ~TaskManager(); + bool shouldTerminate(); + void clearTerminate(); public Q_SLOTS: void info(const std::string &text); + void terminate_thread(); Q_SIGNALS: + void terminate(); void parsejson(const std::string &); void log(const std::string &text); + + private: + QMutex mutex; + bool toTerminate; }; #endif // WORKER_H -- cgit v1.2.3 From 5cb893aebdfdf711755b9bf610b36b8ff2d942ff Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 22 Jun 2018 12:24:50 +0200 Subject: terminate on close --- gui/ice40/worker.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gui') diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index a309f868..4b101e7e 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -61,6 +61,8 @@ TaskManager::TaskManager(Context *ctx) : toTerminate(false) TaskManager::~TaskManager() { + if (workerThread.isRunning()) + terminate_thread(); workerThread.quit(); workerThread.wait(); } -- cgit v1.2.3 From 11d99853ab4514b1f6b87c5beb87c91f50e702a6 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 22 Jun 2018 12:49:20 +0200 Subject: more task control --- gui/CMakeLists.txt | 2 +- gui/base.qrc | 8 ++++++++ gui/basewindow.cc | 2 +- gui/dummy/nextpnr.qrc | 2 ++ gui/ice40/mainwindow.cc | 35 ++++++++++++++++++++++++++++++---- gui/ice40/nextpnr.qrc | 7 +++++++ gui/ice40/resources/control_pause.png | Bin 0 -> 598 bytes gui/ice40/resources/control_play.png | Bin 0 -> 592 bytes gui/ice40/resources/control_stop.png | Bin 0 -> 403 bytes gui/ice40/worker.cc | 22 ++++++++++++++++++++- gui/ice40/worker.h | 4 ++++ gui/nextpnr.qrc | 8 -------- 12 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 gui/base.qrc create mode 100644 gui/dummy/nextpnr.qrc create mode 100644 gui/ice40/nextpnr.qrc create mode 100644 gui/ice40/resources/control_pause.png create mode 100644 gui/ice40/resources/control_play.png create mode 100644 gui/ice40/resources/control_stop.png delete mode 100644 gui/nextpnr.qrc (limited to 'gui') diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index b4dcde11..f19d2d20 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -3,7 +3,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) aux_source_directory(. GUI_SOURCE_FILES) aux_source_directory(${family}/ GUI_SOURCE_FILES) -set(_RESOURCES nextpnr.qrc) +set(_RESOURCES base.qrc ${family}/nextpnr.qrc) qt5_add_resources(GUI_RESOURCE_FILES ${_RESOURCES}) diff --git a/gui/base.qrc b/gui/base.qrc new file mode 100644 index 00000000..b9e2f237 --- /dev/null +++ b/gui/base.qrc @@ -0,0 +1,8 @@ + + + resources/new.png + resources/open.png + resources/save.png + resources/exit.png + + diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 9020a719..b7258dd3 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -13,7 +13,7 @@ BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) : QMainWindow(parent), ctx(_ctx) { - Q_INIT_RESOURCE(nextpnr); + Q_INIT_RESOURCE(base); qRegisterMetaType(); log_files.clear(); diff --git a/gui/dummy/nextpnr.qrc b/gui/dummy/nextpnr.qrc new file mode 100644 index 00000000..03585ec0 --- /dev/null +++ b/gui/dummy/nextpnr.qrc @@ -0,0 +1,2 @@ + + diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index e36464a0..9ce7f41e 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -14,6 +14,8 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, parent) { + Q_INIT_RESOURCE(nextpnr); + std::string title = "nextpnr-ice40 - " + ctx->getChipName(); setWindowTitle(title.c_str()); @@ -30,11 +32,36 @@ void MainWindow::createMenu() QMenu *menu_Custom = new QMenu("&ICE 40", menuBar); menuBar->addAction(menu_Custom->menuAction()); - QAction *actionTerminate = new QAction("Terminate", this); - actionTerminate->setStatusTip("Terminate running task"); - connect(actionTerminate, SIGNAL(triggered()), task, + QAction *actionPlay = new QAction("Play", this); + QIcon icon1; + icon1.addFile(QStringLiteral(":/icons/resources/control_play.png")); + actionPlay->setIcon(icon1); + actionPlay->setStatusTip("Continue running task"); + connect(actionPlay, SIGNAL(triggered()), task, + SLOT(continue_thread())); + + QAction *actionPause = new QAction("Pause", this); + QIcon icon2; + icon2.addFile(QStringLiteral(":/icons/resources/control_pause.png")); + actionPause->setIcon(icon2); + actionPause->setStatusTip("Pause running task"); + connect(actionPause, SIGNAL(triggered()), task, + SLOT(pause_thread())); + + QAction *actionStop = new QAction("Stop", this); + QIcon icon3; + icon3.addFile(QStringLiteral(":/icons/resources/control_stop.png")); + actionStop->setIcon(icon3); + actionStop->setStatusTip("Stop running task"); + connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread())); - menu_Custom->addAction(actionTerminate); + + QToolBar *taskToolBar = new QToolBar(); + addToolBar(Qt::TopToolBarArea, taskToolBar); + + taskToolBar->addAction(actionPlay); + taskToolBar->addAction(actionPause); + taskToolBar->addAction(actionStop); } void MainWindow::open() diff --git a/gui/ice40/nextpnr.qrc b/gui/ice40/nextpnr.qrc new file mode 100644 index 00000000..cbdb8b26 --- /dev/null +++ b/gui/ice40/nextpnr.qrc @@ -0,0 +1,7 @@ + + + resources/control_play.png + resources/control_pause.png + resources/control_stop.png + + diff --git a/gui/ice40/resources/control_pause.png b/gui/ice40/resources/control_pause.png new file mode 100644 index 00000000..2d9ce9c4 Binary files /dev/null and b/gui/ice40/resources/control_pause.png differ diff --git a/gui/ice40/resources/control_play.png b/gui/ice40/resources/control_play.png new file mode 100644 index 00000000..0846555d Binary files /dev/null and b/gui/ice40/resources/control_play.png differ diff --git a/gui/ice40/resources/control_stop.png b/gui/ice40/resources/control_stop.png new file mode 100644 index 00000000..893bb60e Binary files /dev/null and b/gui/ice40/resources/control_stop.png differ diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index 4b101e7e..3854c67f 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -22,6 +22,9 @@ Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx) parent->clearTerminate(); throw WorkerInterruptionRequested(); } + while (parent->isPaused()){ + QThread::sleep(1); + } }; } @@ -49,7 +52,7 @@ void Worker::parsejson(const std::string &filename) } } -TaskManager::TaskManager(Context *ctx) : toTerminate(false) +TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false) { Worker *worker = new Worker(ctx, this); worker->moveToThread(&workerThread); @@ -85,4 +88,21 @@ void TaskManager::clearTerminate() { QMutexLocker locker(&mutex); toTerminate = false; +} + +void TaskManager::pause_thread() +{ + QMutexLocker locker(&mutex); + toPause = true; +} + +void TaskManager::continue_thread() +{ + QMutexLocker locker(&mutex); + toPause = false; +} +bool TaskManager::isPaused() +{ + QMutexLocker locker(&mutex); + return toPause; } \ No newline at end of file diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h index a2d220bd..49d1df4d 100644 --- a/gui/ice40/worker.h +++ b/gui/ice40/worker.h @@ -34,9 +34,12 @@ class TaskManager : public QObject ~TaskManager(); bool shouldTerminate(); void clearTerminate(); + bool isPaused(); public Q_SLOTS: void info(const std::string &text); void terminate_thread(); + void pause_thread(); + void continue_thread(); Q_SIGNALS: void terminate(); void parsejson(const std::string &); @@ -45,6 +48,7 @@ class TaskManager : public QObject private: QMutex mutex; bool toTerminate; + bool toPause; }; #endif // WORKER_H diff --git a/gui/nextpnr.qrc b/gui/nextpnr.qrc deleted file mode 100644 index b9e2f237..00000000 --- a/gui/nextpnr.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - resources/new.png - resources/open.png - resources/save.png - resources/exit.png - - -- cgit v1.2.3 From 7f368282700172925428e45f23b8b61e0bf39f94 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 22 Jun 2018 13:10:27 +0200 Subject: fixed namespace for gui section --- gui/basewindow.cc | 8 +++++++- gui/basewindow.h | 7 ++++--- gui/designwidget.cc | 4 ++++ gui/designwidget.h | 5 +++-- gui/dummy/mainwindow.cc | 10 +++++++++- gui/dummy/mainwindow.h | 5 +++-- gui/fpgaviewwidget.cc | 4 ++++ gui/fpgaviewwidget.h | 5 +++-- gui/ice40/mainwindow.cc | 22 +++++++++++++--------- gui/ice40/mainwindow.h | 5 +++-- gui/ice40/worker.cc | 10 +++++++--- gui/ice40/worker.h | 5 +++-- gui/infotab.cc | 4 ++++ gui/infotab.h | 5 +++-- gui/line_editor.cc | 7 +++++-- gui/line_editor.h | 5 +++++ gui/pythontab.cc | 6 +++++- gui/pythontab.h | 5 +++-- 18 files changed, 88 insertions(+), 34 deletions(-) (limited to 'gui') diff --git a/gui/basewindow.cc b/gui/basewindow.cc index b7258dd3..f16b205d 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -10,10 +10,14 @@ #include "mainwindow.h" #include "pythontab.h" +static void initBasenameResource() { Q_INIT_RESOURCE(base); } + +NEXTPNR_NAMESPACE_BEGIN + BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) : QMainWindow(parent), ctx(_ctx) { - Q_INIT_RESOURCE(base); + initBasenameResource(); qRegisterMetaType(); log_files.clear(); @@ -114,3 +118,5 @@ void BaseMainWindow::createMenusAndBars() mainToolBar->addAction(actionOpen); mainToolBar->addAction(actionSave); } + +NEXTPNR_NAMESPACE_END diff --git a/gui/basewindow.h b/gui/basewindow.h index b20d4621..55e4affc 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -11,11 +11,10 @@ #include #include -// FIXME -USING_NEXTPNR_NAMESPACE - Q_DECLARE_METATYPE(std::string) +NEXTPNR_NAMESPACE_BEGIN + class BaseMainWindow : public QMainWindow { Q_OBJECT @@ -45,4 +44,6 @@ class BaseMainWindow : public QMainWindow QStatusBar *statusBar; }; +NEXTPNR_NAMESPACE_END + #endif // BASEMAINWINDOW_H diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 9bb25992..7b1ce543 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -7,6 +7,8 @@ #include "fpgaviewwidget.h" #include "pybindings.h" +NEXTPNR_NAMESPACE_BEGIN + enum class ElementType { BEL, @@ -234,3 +236,5 @@ void DesignWidget::selectObject() { Q_EMIT info("selected " + itemContextMenu->text(0).toStdString() + "\n"); } + +NEXTPNR_NAMESPACE_END diff --git a/gui/designwidget.h b/gui/designwidget.h index 9682726c..5bd12d4d 100644 --- a/gui/designwidget.h +++ b/gui/designwidget.h @@ -7,8 +7,7 @@ #include "qttreepropertybrowser.h" #include "qtvariantproperty.h" -// FIXME -USING_NEXTPNR_NAMESPACE +NEXTPNR_NAMESPACE_BEGIN class DesignWidget : public QWidget { @@ -45,4 +44,6 @@ class DesignWidget : public QWidget QMap idToProperty; }; +NEXTPNR_NAMESPACE_END + #endif // DESIGNWIDGET_H diff --git a/gui/dummy/mainwindow.cc b/gui/dummy/mainwindow.cc index 7982c5f5..da162dd0 100644 --- a/gui/dummy/mainwindow.cc +++ b/gui/dummy/mainwindow.cc @@ -1,8 +1,14 @@ #include "mainwindow.h" +static void initMainResource() { Q_INIT_RESOURCE(nextpnr); } + +NEXTPNR_NAMESPACE_BEGIN + MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, parent) { + initMainResource(); + std::string title = "nextpnr-dummy - " + ctx->getChipName(); setWindowTitle(title.c_str()); @@ -19,4 +25,6 @@ void MainWindow::createMenu() void MainWindow::open() {} -bool MainWindow::save() { return false; } \ No newline at end of file +bool MainWindow::save() { return false; } + +NEXTPNR_NAMESPACE_END diff --git a/gui/dummy/mainwindow.h b/gui/dummy/mainwindow.h index c9690f2c..c2786906 100644 --- a/gui/dummy/mainwindow.h +++ b/gui/dummy/mainwindow.h @@ -3,8 +3,7 @@ #include "../basewindow.h" -// FIXME -USING_NEXTPNR_NAMESPACE +NEXTPNR_NAMESPACE_BEGIN class MainWindow : public BaseMainWindow { @@ -22,4 +21,6 @@ class MainWindow : public BaseMainWindow virtual bool save(); }; +NEXTPNR_NAMESPACE_END + #endif // MAINWINDOW_H diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 6b7e7787..8119eae3 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -6,6 +6,8 @@ #include #include "mainwindow.h" +NEXTPNR_NAMESPACE_BEGIN + FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), m_xMove(0), m_yMove(0), m_zDistance(1.0) { @@ -173,3 +175,5 @@ void FPGAViewWidget::wheelEvent(QWheelEvent *event) setZoom(step.y() * -0.1f); } } + +NEXTPNR_NAMESPACE_END diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index 2407f757..fc3ca562 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -7,8 +7,7 @@ #include #include "nextpnr.h" -// FIXME -USING_NEXTPNR_NAMESPACE +NEXTPNR_NAMESPACE_BEGIN class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions { @@ -49,4 +48,6 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions Context *ctx; }; +NEXTPNR_NAMESPACE_END + #endif diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index 9ce7f41e..4c7bc18f 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -11,11 +11,15 @@ #include "place_sa.h" #include "route.h" +static void initMainResource() { Q_INIT_RESOURCE(nextpnr); } + +NEXTPNR_NAMESPACE_BEGIN + MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, parent) { - Q_INIT_RESOURCE(nextpnr); - + initMainResource(); + std::string title = "nextpnr-ice40 - " + ctx->getChipName(); setWindowTitle(title.c_str()); @@ -37,24 +41,21 @@ void MainWindow::createMenu() icon1.addFile(QStringLiteral(":/icons/resources/control_play.png")); actionPlay->setIcon(icon1); actionPlay->setStatusTip("Continue running task"); - connect(actionPlay, SIGNAL(triggered()), task, - SLOT(continue_thread())); + connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread())); QAction *actionPause = new QAction("Pause", this); QIcon icon2; icon2.addFile(QStringLiteral(":/icons/resources/control_pause.png")); actionPause->setIcon(icon2); actionPause->setStatusTip("Pause running task"); - connect(actionPause, SIGNAL(triggered()), task, - SLOT(pause_thread())); + connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread())); QAction *actionStop = new QAction("Stop", this); QIcon icon3; icon3.addFile(QStringLiteral(":/icons/resources/control_stop.png")); actionStop->setIcon(icon3); actionStop->setStatusTip("Stop running task"); - connect(actionStop, SIGNAL(triggered()), task, - SLOT(terminate_thread())); + connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread())); QToolBar *taskToolBar = new QToolBar(); addToolBar(Qt::TopToolBarArea, taskToolBar); @@ -75,4 +76,7 @@ void MainWindow::open() Q_EMIT task->parsejson(fn); } } -bool MainWindow::save() { return false; } \ No newline at end of file + +bool MainWindow::save() { return false; } + +NEXTPNR_NAMESPACE_END \ No newline at end of file diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h index fd65f9ae..712f341a 100644 --- a/gui/ice40/mainwindow.h +++ b/gui/ice40/mainwindow.h @@ -4,8 +4,7 @@ #include "../basewindow.h" #include "worker.h" -// FIXME -USING_NEXTPNR_NAMESPACE +NEXTPNR_NAMESPACE_BEGIN class MainWindow : public BaseMainWindow { @@ -26,4 +25,6 @@ class MainWindow : public BaseMainWindow TaskManager *task; }; +NEXTPNR_NAMESPACE_END + #endif // MAINWINDOW_H diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index 3854c67f..9549f659 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -10,6 +10,8 @@ #include "route.h" #include "timing.h" +NEXTPNR_NAMESPACE_BEGIN + struct WorkerInterruptionRequested { }; @@ -22,7 +24,7 @@ Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx) parent->clearTerminate(); throw WorkerInterruptionRequested(); } - while (parent->isPaused()){ + while (parent->isPaused()) { QThread::sleep(1); } }; @@ -64,7 +66,7 @@ TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false) TaskManager::~TaskManager() { - if (workerThread.isRunning()) + if (workerThread.isRunning()) terminate_thread(); workerThread.quit(); workerThread.wait(); @@ -105,4 +107,6 @@ bool TaskManager::isPaused() { QMutexLocker locker(&mutex); return toPause; -} \ No newline at end of file +} + +NEXTPNR_NAMESPACE_END diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h index 49d1df4d..181fafa3 100644 --- a/gui/ice40/worker.h +++ b/gui/ice40/worker.h @@ -5,8 +5,7 @@ #include #include "nextpnr.h" -// FIXME -USING_NEXTPNR_NAMESPACE +NEXTPNR_NAMESPACE_BEGIN class TaskManager; @@ -51,4 +50,6 @@ class TaskManager : public QObject bool toPause; }; +NEXTPNR_NAMESPACE_END + #endif // WORKER_H diff --git a/gui/infotab.cc b/gui/infotab.cc index 7690b83c..29d557d2 100644 --- a/gui/infotab.cc +++ b/gui/infotab.cc @@ -1,6 +1,8 @@ #include "infotab.h" #include +NEXTPNR_NAMESPACE_BEGIN + InfoTab::InfoTab(QWidget *parent) : QWidget(parent) { plainTextEdit = new QPlainTextEdit(); @@ -37,3 +39,5 @@ void InfoTab::showContextMenu(const QPoint &pt) } void InfoTab::clearBuffer() { plainTextEdit->clear(); } + +NEXTPNR_NAMESPACE_END diff --git a/gui/infotab.h b/gui/infotab.h index d7f1408c..3e0220c4 100644 --- a/gui/infotab.h +++ b/gui/infotab.h @@ -5,8 +5,7 @@ #include #include "nextpnr.h" -// FIXME -USING_NEXTPNR_NAMESPACE +NEXTPNR_NAMESPACE_BEGIN class InfoTab : public QWidget { @@ -24,4 +23,6 @@ class InfoTab : public QWidget QMenu *contextMenu; }; +NEXTPNR_NAMESPACE_END + #endif // INFOTAB_H diff --git a/gui/line_editor.cc b/gui/line_editor.cc index b5ed955f..6299c9cc 100644 --- a/gui/line_editor.cc +++ b/gui/line_editor.cc @@ -1,7 +1,8 @@ #include "line_editor.h" - #include +NEXTPNR_NAMESPACE_BEGIN + LineEditor::LineEditor(QWidget *parent) : QLineEdit(parent), index(0) { setContextMenuPolicy(Qt::CustomContextMenu); @@ -64,4 +65,6 @@ void LineEditor::clearHistory() lines.clear(); index = 0; clear(); -} \ No newline at end of file +} + +NEXTPNR_NAMESPACE_END \ No newline at end of file diff --git a/gui/line_editor.h b/gui/line_editor.h index 15b675f9..5f27e502 100644 --- a/gui/line_editor.h +++ b/gui/line_editor.h @@ -3,6 +3,9 @@ #include #include +#include "nextpnr.h" + +NEXTPNR_NAMESPACE_BEGIN class LineEditor : public QLineEdit { @@ -28,4 +31,6 @@ class LineEditor : public QLineEdit QMenu *contextMenu; }; +NEXTPNR_NAMESPACE_END + #endif // LINE_EDITOR_H diff --git a/gui/pythontab.cc b/gui/pythontab.cc index 96a6c4b9..19aa0162 100644 --- a/gui/pythontab.cc +++ b/gui/pythontab.cc @@ -3,6 +3,8 @@ #include "emb.h" #include "pybindings.h" +NEXTPNR_NAMESPACE_BEGIN + PythonTab::PythonTab(QWidget *parent) : QWidget(parent) { PyImport_ImportModule("emb"); @@ -114,4 +116,6 @@ void PythonTab::showContextMenu(const QPoint &pt) contextMenu->exec(mapToGlobal(pt)); } -void PythonTab::clearBuffer() { plainTextEdit->clear(); } \ No newline at end of file +void PythonTab::clearBuffer() { plainTextEdit->clear(); } + +NEXTPNR_NAMESPACE_END diff --git a/gui/pythontab.h b/gui/pythontab.h index 5aed8b0b..52a8ff8d 100644 --- a/gui/pythontab.h +++ b/gui/pythontab.h @@ -8,8 +8,7 @@ #include "line_editor.h" #include "nextpnr.h" -// FIXME -USING_NEXTPNR_NAMESPACE +NEXTPNR_NAMESPACE_BEGIN class PythonTab : public QWidget { @@ -33,4 +32,6 @@ class PythonTab : public QWidget emb::stdout_write_type write; }; +NEXTPNR_NAMESPACE_END + #endif // PYTHONTAB_H -- cgit v1.2.3