2018-06-22 22:21:20 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
|
2018-07-27 09:28:01 +08:00
|
|
|
* Copyright (C) 2018 Serge Bazanski <q3k@symbioticeda.com>
|
2018-06-22 22:21:20 +08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-15 18:22:44 +08:00
|
|
|
#include <QAction>
|
2018-07-16 02:31:42 +08:00
|
|
|
#include <QCoreApplication>
|
2018-06-19 21:17:10 +08:00
|
|
|
#include <QFileDialog>
|
2018-06-15 18:22:44 +08:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QSplitter>
|
2018-06-15 02:03:59 +08:00
|
|
|
#include "designwidget.h"
|
|
|
|
#include "fpgaviewwidget.h"
|
2018-06-19 21:17:10 +08:00
|
|
|
#include "log.h"
|
2018-06-21 19:55:36 +08:00
|
|
|
#include "mainwindow.h"
|
2018-06-15 02:03:59 +08:00
|
|
|
#include "pythontab.h"
|
2018-06-21 21:41:40 +08:00
|
|
|
|
2018-06-22 19:10:27 +08:00
|
|
|
static void initBasenameResource() { Q_INIT_RESOURCE(base); }
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-07-13 15:14:48 +08:00
|
|
|
BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent)
|
|
|
|
: QMainWindow(parent), ctx(std::move(context))
|
2018-06-15 00:37:57 +08:00
|
|
|
{
|
2018-06-22 19:10:27 +08:00
|
|
|
initBasenameResource();
|
2018-06-21 21:41:40 +08:00
|
|
|
qRegisterMetaType<std::string>();
|
2018-06-20 22:13:49 +08:00
|
|
|
|
2018-06-19 21:17:10 +08:00
|
|
|
log_files.clear();
|
|
|
|
log_streams.clear();
|
|
|
|
|
2018-07-14 23:58:58 +08:00
|
|
|
setObjectName("BaseMainWindow");
|
2018-06-15 18:22:44 +08:00
|
|
|
resize(1024, 768);
|
2018-06-15 00:37:57 +08:00
|
|
|
|
2018-06-15 18:22:44 +08:00
|
|
|
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);
|
2018-06-15 00:37:57 +08:00
|
|
|
|
2018-07-16 02:31:42 +08:00
|
|
|
designview = new DesignWidget();
|
2018-06-15 02:24:05 +08:00
|
|
|
designview->setMinimumWidth(300);
|
2018-06-15 18:22:44 +08:00
|
|
|
splitter_h->addWidget(designview);
|
2018-06-29 00:06:31 +08:00
|
|
|
|
2018-06-19 21:17:10 +08:00
|
|
|
tabWidget = new QTabWidget();
|
2018-07-14 20:06:05 +08:00
|
|
|
|
|
|
|
console = new PythonTab();
|
|
|
|
tabWidget->addTab(console, "Console");
|
|
|
|
connect(this, SIGNAL(contextChanged(Context *)), console, SLOT(newContext(Context *)));
|
2018-06-21 20:12:02 +08:00
|
|
|
|
|
|
|
centralTabWidget = new QTabWidget();
|
2018-07-17 03:15:49 +08:00
|
|
|
centralTabWidget->setTabsClosable(true);
|
|
|
|
connect(centralTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
|
|
|
|
2018-07-26 19:21:46 +08:00
|
|
|
fpgaView = new FPGAViewWidget();
|
2018-08-02 20:59:48 +08:00
|
|
|
centralTabWidget->addTab(fpgaView, "Device");
|
2018-07-17 03:15:49 +08:00
|
|
|
centralTabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0);
|
2018-06-26 21:47:22 +08:00
|
|
|
|
2018-06-29 00:06:31 +08:00
|
|
|
connect(this, SIGNAL(contextChanged(Context *)), fpgaView, SLOT(newContext(Context *)));
|
2018-07-27 09:14:40 +08:00
|
|
|
connect(designview, SIGNAL(selected(std::vector<DecalXY>, bool)), fpgaView,
|
|
|
|
SLOT(onSelectedArchItem(std::vector<DecalXY>, bool)));
|
|
|
|
connect(fpgaView, SIGNAL(clickedBel(BelId, bool)), designview, SLOT(onClickedBel(BelId, bool)));
|
|
|
|
connect(fpgaView, SIGNAL(clickedWire(WireId, bool)), designview, SLOT(onClickedWire(WireId, bool)));
|
2018-07-27 09:28:01 +08:00
|
|
|
connect(fpgaView, SIGNAL(clickedPip(PipId, bool)), designview, SLOT(onClickedPip(PipId, bool)));
|
2018-07-29 21:21:34 +08:00
|
|
|
connect(designview, SIGNAL(zoomSelected()), fpgaView, SLOT(zoomSelected()));
|
2018-06-21 20:12:02 +08:00
|
|
|
|
2018-07-15 23:50:58 +08:00
|
|
|
connect(designview, SIGNAL(highlight(std::vector<DecalXY>, int)), fpgaView,
|
|
|
|
SLOT(onHighlightGroupChanged(std::vector<DecalXY>, int)));
|
|
|
|
|
2018-07-16 02:31:42 +08:00
|
|
|
connect(this, SIGNAL(contextChanged(Context *)), designview, SLOT(newContext(Context *)));
|
|
|
|
connect(this, SIGNAL(updateTreeView()), designview, SLOT(updateTree()));
|
|
|
|
|
|
|
|
connect(designview, SIGNAL(info(std::string)), this, SLOT(writeInfo(std::string)));
|
|
|
|
|
2018-06-21 20:12:02 +08:00
|
|
|
splitter_v->addWidget(centralTabWidget);
|
2018-06-15 18:22:44 +08:00
|
|
|
splitter_v->addWidget(tabWidget);
|
2018-06-15 00:37:57 +08:00
|
|
|
}
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
BaseMainWindow::~BaseMainWindow() {}
|
2018-06-15 17:10:11 +08:00
|
|
|
|
2018-07-17 03:15:49 +08:00
|
|
|
void BaseMainWindow::closeTab(int index) { delete centralTabWidget->widget(index); }
|
|
|
|
|
2018-07-14 20:06:05 +08:00
|
|
|
void BaseMainWindow::writeInfo(std::string text) { console->info(text); }
|
2018-06-15 18:22:44 +08:00
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
void BaseMainWindow::createMenusAndBars()
|
2018-06-15 18:22:44 +08:00
|
|
|
{
|
2018-07-15 18:39:19 +08:00
|
|
|
actionNew = new QAction("New", this);
|
2018-07-14 23:58:58 +08:00
|
|
|
actionNew->setIcon(QIcon(":/icons/resources/new.png"));
|
2018-06-26 20:17:17 +08:00
|
|
|
actionNew->setShortcuts(QKeySequence::New);
|
|
|
|
actionNew->setStatusTip("New project file");
|
|
|
|
connect(actionNew, SIGNAL(triggered()), this, SLOT(new_proj()));
|
|
|
|
|
2018-07-15 18:39:19 +08:00
|
|
|
actionOpen = new QAction("Open", this);
|
2018-07-14 23:58:58 +08:00
|
|
|
actionOpen->setIcon(QIcon(":/icons/resources/open.png"));
|
2018-06-19 21:17:10 +08:00
|
|
|
actionOpen->setShortcuts(QKeySequence::Open);
|
2018-06-26 20:17:17 +08:00
|
|
|
actionOpen->setStatusTip("Open an existing project file");
|
|
|
|
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
|
2018-06-15 18:22:44 +08:00
|
|
|
|
2018-07-21 18:15:50 +08:00
|
|
|
actionSave = new QAction("Save", this);
|
2018-07-14 23:58:58 +08:00
|
|
|
actionSave->setIcon(QIcon(":/icons/resources/save.png"));
|
2018-06-19 21:17:10 +08:00
|
|
|
actionSave->setShortcuts(QKeySequence::Save);
|
2018-06-26 20:17:17 +08:00
|
|
|
actionSave->setStatusTip("Save existing project to disk");
|
2018-06-19 21:17:10 +08:00
|
|
|
actionSave->setEnabled(false);
|
2018-07-14 23:58:58 +08:00
|
|
|
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
|
2018-06-15 18:22:44 +08:00
|
|
|
|
2018-07-15 18:39:19 +08:00
|
|
|
QAction *actionExit = new QAction("Exit", this);
|
2018-07-14 23:58:58 +08:00
|
|
|
actionExit->setIcon(QIcon(":/icons/resources/exit.png"));
|
2018-06-19 21:17:10 +08:00
|
|
|
actionExit->setShortcuts(QKeySequence::Quit);
|
|
|
|
actionExit->setStatusTip("Exit the application");
|
|
|
|
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
2018-06-15 18:22:44 +08:00
|
|
|
|
|
|
|
QAction *actionAbout = new QAction("About", this);
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
menuBar = new QMenuBar();
|
2018-06-15 18:22:44 +08:00
|
|
|
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);
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
mainToolBar = new QToolBar();
|
2018-06-15 18:22:44 +08:00
|
|
|
addToolBar(Qt::TopToolBarArea, mainToolBar);
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
statusBar = new QStatusBar();
|
2018-07-12 20:54:16 +08:00
|
|
|
progressBar = new QProgressBar(statusBar);
|
|
|
|
progressBar->setAlignment(Qt::AlignRight);
|
|
|
|
progressBar->setMaximumSize(180, 19);
|
|
|
|
statusBar->addPermanentWidget(progressBar);
|
|
|
|
progressBar->setValue(0);
|
|
|
|
progressBar->setEnabled(false);
|
2018-06-15 18:22:44 +08:00
|
|
|
setStatusBar(statusBar);
|
|
|
|
|
2018-06-26 20:17:17 +08:00
|
|
|
menu_File->addAction(actionNew);
|
2018-06-15 18:22:44 +08:00
|
|
|
menu_File->addAction(actionOpen);
|
|
|
|
menu_File->addAction(actionSave);
|
|
|
|
menu_File->addSeparator();
|
|
|
|
menu_File->addAction(actionExit);
|
|
|
|
menu_Help->addAction(actionAbout);
|
|
|
|
|
2018-06-26 20:17:17 +08:00
|
|
|
mainToolBar->addAction(actionNew);
|
2018-06-15 18:22:44 +08:00
|
|
|
mainToolBar->addAction(actionOpen);
|
|
|
|
mainToolBar->addAction(actionSave);
|
2018-06-19 21:17:10 +08:00
|
|
|
}
|
2018-06-22 19:10:27 +08:00
|
|
|
|
2018-07-26 19:21:46 +08:00
|
|
|
void BaseMainWindow::createGraphicsBar()
|
|
|
|
{
|
|
|
|
QAction *actionZoomIn = new QAction("Zoom In", this);
|
|
|
|
actionZoomIn->setIcon(QIcon(":/icons/resources/zoom_in.png"));
|
2018-07-26 23:26:05 +08:00
|
|
|
connect(actionZoomIn, SIGNAL(triggered()), fpgaView, SLOT(zoomIn()));
|
2018-07-26 19:21:46 +08:00
|
|
|
|
|
|
|
QAction *actionZoomOut = new QAction("Zoom Out", this);
|
|
|
|
actionZoomOut->setIcon(QIcon(":/icons/resources/zoom_out.png"));
|
2018-07-26 23:26:05 +08:00
|
|
|
connect(actionZoomOut, SIGNAL(triggered()), fpgaView, SLOT(zoomOut()));
|
2018-07-26 19:21:46 +08:00
|
|
|
|
|
|
|
QAction *actionZoomSelected = new QAction("Zoom Selected", this);
|
|
|
|
actionZoomSelected->setIcon(QIcon(":/icons/resources/shape_handles.png"));
|
2018-07-26 23:26:05 +08:00
|
|
|
connect(actionZoomSelected, SIGNAL(triggered()), fpgaView, SLOT(zoomSelected()));
|
2018-07-26 19:21:46 +08:00
|
|
|
|
|
|
|
QAction *actionZoomOutbound = new QAction("Zoom Outbound", this);
|
|
|
|
actionZoomOutbound->setIcon(QIcon(":/icons/resources/shape_square.png"));
|
2018-07-26 23:26:05 +08:00
|
|
|
connect(actionZoomOutbound, SIGNAL(triggered()), fpgaView, SLOT(zoomOutbound()));
|
2018-07-26 19:21:46 +08:00
|
|
|
|
|
|
|
graphicsToolBar = new QToolBar();
|
|
|
|
addToolBar(Qt::TopToolBarArea, graphicsToolBar);
|
|
|
|
graphicsToolBar->addAction(actionZoomIn);
|
|
|
|
graphicsToolBar->addAction(actionZoomOut);
|
|
|
|
graphicsToolBar->addAction(actionZoomSelected);
|
|
|
|
graphicsToolBar->addAction(actionZoomOutbound);
|
|
|
|
}
|
|
|
|
|
2018-06-22 19:10:27 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|