aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-06-21 14:27:50 +0200
committerClifford Wolf <clifford@clifford.at>2018-06-21 14:27:50 +0200
commit477c33efba4362282cf88f02cf4d17f13d3ad8fd (patch)
tree3dd37bc2f2d15608138c45455b7cfeab0a892ccf /gui
parent08020400b379a0c2d7069bbd62f43782d438598b (diff)
parent23fe31da44a2e2596335c09ae983217ffbc8f6b1 (diff)
downloadnextpnr-477c33efba4362282cf88f02cf4d17f13d3ad8fd.tar.gz
nextpnr-477c33efba4362282cf88f02cf4d17f13d3ad8fd.tar.bz2
nextpnr-477c33efba4362282cf88f02cf4d17f13d3ad8fd.zip
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
Diffstat (limited to 'gui')
-rw-r--r--gui/CMakeLists.txt3
-rw-r--r--gui/basewindow.cc (renamed from gui/mainwindow.cc)29
-rw-r--r--gui/basewindow.h44
-rw-r--r--gui/dummy/mainwindow.cc18
-rw-r--r--gui/dummy/mainwindow.h21
-rw-r--r--gui/emb.cc138
-rw-r--r--gui/emb.h20
-rw-r--r--gui/fpgaviewwidget.cc4
-rw-r--r--gui/ice40/mainwindow.cc28
-rw-r--r--gui/ice40/mainwindow.h21
-rw-r--r--gui/mainwindow.h36
11 files changed, 147 insertions, 215 deletions
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/mainwindow.cc b/gui/basewindow.cc
index 91232390..fa9528fc 100644
--- a/gui/mainwindow.cc
+++ b/gui/basewindow.cc
@@ -1,28 +1,23 @@
-#include "mainwindow.h"
#include <QAction>
#include <QFileDialog>
#include <QGridLayout>
#include <QIcon>
-#include <QMenu>
-#include <QMenuBar>
#include <QSplitter>
-#include <QStatusBar>
-#include <QToolBar>
#include <fstream>
#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 "pybindings.h"
#include "route.h"
//#include "bitstream.h"
#include "design_utils.h"
-MainWindow::MainWindow(Context *_ctx, QWidget *parent)
+BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent)
: QMainWindow(parent), ctx(_ctx)
{
Q_INIT_RESOURCE(nextpnr);
@@ -31,9 +26,7 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent)
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"));
+ setObjectName(QStringLiteral("BaseMainWindow"));
resize(1024, 768);
createMenusAndBars();
@@ -68,11 +61,11 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent)
splitter_v->addWidget(tabWidget);
}
-MainWindow::~MainWindow() {}
+BaseMainWindow::~BaseMainWindow() {}
-void MainWindow::writeInfo(std::string text) { info->info(text); }
+void BaseMainWindow::writeInfo(std::string text) { info->info(text); }
-void MainWindow::createMenusAndBars()
+void BaseMainWindow::createMenusAndBars()
{
QAction *actionOpen = new QAction("Open", this);
QIcon icon1;
@@ -101,7 +94,7 @@ void MainWindow::createMenusAndBars()
QAction *actionAbout = new QAction("About", this);
- QMenuBar *menuBar = new 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);
@@ -109,10 +102,10 @@ void MainWindow::createMenusAndBars()
menuBar->addAction(menu_Help->menuAction());
setMenuBar(menuBar);
- QToolBar *mainToolBar = new QToolBar();
+ mainToolBar = new QToolBar();
addToolBar(Qt::TopToolBarArea, mainToolBar);
- QStatusBar *statusBar = new QStatusBar();
+ statusBar = new QStatusBar();
setStatusBar(statusBar);
menu_File->addAction(actionOpen);
@@ -125,7 +118,7 @@ void MainWindow::createMenusAndBars()
mainToolBar->addAction(actionSave);
}
-void MainWindow::open()
+void BaseMainWindow::open()
{
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
QString("*.json"));
@@ -142,4 +135,4 @@ void MainWindow::open()
}
}
-bool MainWindow::save() { return false; }
+bool BaseMainWindow::save() { return false; }
diff --git a/gui/basewindow.h b/gui/basewindow.h
new file mode 100644
index 00000000..630e0f84
--- /dev/null
+++ b/gui/basewindow.h
@@ -0,0 +1,44 @@
+#ifndef BASEMAINWINDOW_H
+#define BASEMAINWINDOW_H
+
+#include "infotab.h"
+#include "nextpnr.h"
+
+#include <QMainWindow>
+#include <QMenu>
+#include <QMenuBar>
+#include <QStatusBar>
+#include <QTabWidget>
+#include <QToolBar>
+
+// 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..a9420524
--- /dev/null
+++ b/gui/dummy/mainwindow.cc
@@ -0,0 +1,18 @@
+#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 <mateusz@loskot.net>
-// 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 <Python.h>
-#include <functional>
-#include <iostream>
-#include <string>
-
-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<Stdout *>(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<PyObject *>(&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<Stdout *>(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 <mateusz@loskot.net>
-// 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 <functional>
-#include <iostream>
-#include <string>
-
-namespace emb {
-typedef std::function<void(std::string)> 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<MainWindow *>(getMainWindow())->getContext();
+ ctx = qobject_cast<BaseMainWindow *>(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..3744cdc7
--- /dev/null
+++ b/gui/ice40/mainwindow.cc
@@ -0,0 +1,28 @@
+#include "mainwindow.h"
+#include <QAction>
+#include <QIcon>
+#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"
+
+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.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 <QMainWindow>
-#include <QTabWidget>
-
-// 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