aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-07-26 13:21:46 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-07-26 13:21:46 +0200
commit4587b8c0001d853ab2fb6f820627f1508e28e316 (patch)
treeca939ce72feda56b0f6144538a74955422572dee /gui
parentc9b9d9b22754778beaa1a922f0df3dac42dd8867 (diff)
downloadnextpnr-4587b8c0001d853ab2fb6f820627f1508e28e316.tar.gz
nextpnr-4587b8c0001d853ab2fb6f820627f1508e28e316.tar.bz2
nextpnr-4587b8c0001d853ab2fb6f820627f1508e28e316.zip
added buttons for new zoom operations
Diffstat (limited to 'gui')
-rw-r--r--gui/base.qrc4
-rw-r--r--gui/basewindow.cc29
-rw-r--r--gui/basewindow.h4
-rw-r--r--gui/fpgaviewwidget.cc39
-rw-r--r--gui/fpgaviewwidget.h6
-rw-r--r--gui/ice40/mainwindow.cc2
-rw-r--r--gui/resources/shape_handles.pngbin0 -> 538 bytes
-rw-r--r--gui/resources/shape_square.pngbin0 -> 353 bytes
-rw-r--r--gui/resources/zoom_in.pngbin0 -> 725 bytes
-rw-r--r--gui/resources/zoom_out.pngbin0 -> 708 bytes
10 files changed, 67 insertions, 17 deletions
diff --git a/gui/base.qrc b/gui/base.qrc
index 1a848f54..7b3fa55c 100644
--- a/gui/base.qrc
+++ b/gui/base.qrc
@@ -10,5 +10,9 @@
<file>resources/resultset_next.png</file>
<file>resources/resultset_last.png</file>
<file>resources/cross.png</file>
+ <file>resources/zoom_in.png</file>
+ <file>resources/zoom_out.png</file>
+ <file>resources/shape_handles.png</file>
+ <file>resources/shape_square.png</file>
</qresource>
</RCC>
diff --git a/gui/basewindow.cc b/gui/basewindow.cc
index 78c2fe3a..11a7fe8d 100644
--- a/gui/basewindow.cc
+++ b/gui/basewindow.cc
@@ -25,7 +25,6 @@
#include <QSplitter>
#include "designwidget.h"
#include "fpgaviewwidget.h"
-#include "jsonparse.h"
#include "log.h"
#include "mainwindow.h"
#include "pythontab.h"
@@ -76,7 +75,7 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
centralTabWidget->setTabsClosable(true);
connect(centralTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
- FPGAViewWidget *fpgaView = new FPGAViewWidget();
+ fpgaView = new FPGAViewWidget();
centralTabWidget->addTab(fpgaView, "Graphics");
centralTabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0);
@@ -163,4 +162,30 @@ void BaseMainWindow::createMenusAndBars()
mainToolBar->addAction(actionSave);
}
+void BaseMainWindow::createGraphicsBar()
+{
+ QAction *actionZoomIn = new QAction("Zoom In", this);
+ actionZoomIn->setIcon(QIcon(":/icons/resources/zoom_in.png"));
+ connect(actionZoomIn, SIGNAL(triggered()), fpgaView, SLOT(zoom_in()));
+
+ QAction *actionZoomOut = new QAction("Zoom Out", this);
+ actionZoomOut->setIcon(QIcon(":/icons/resources/zoom_out.png"));
+ connect(actionZoomOut, SIGNAL(triggered()), fpgaView, SLOT(zoom_out()));
+
+ QAction *actionZoomSelected = new QAction("Zoom Selected", this);
+ actionZoomSelected->setIcon(QIcon(":/icons/resources/shape_handles.png"));
+ connect(actionZoomSelected, SIGNAL(triggered()), fpgaView, SLOT(zoom_selected()));
+
+ QAction *actionZoomOutbound = new QAction("Zoom Outbound", this);
+ actionZoomOutbound->setIcon(QIcon(":/icons/resources/shape_square.png"));
+ connect(actionZoomOutbound, SIGNAL(triggered()), fpgaView, SLOT(zoom_outbound()));
+
+ graphicsToolBar = new QToolBar();
+ addToolBar(Qt::TopToolBarArea, graphicsToolBar);
+ graphicsToolBar->addAction(actionZoomIn);
+ graphicsToolBar->addAction(actionZoomOut);
+ graphicsToolBar->addAction(actionZoomSelected);
+ graphicsToolBar->addAction(actionZoomOutbound);
+}
+
NEXTPNR_NAMESPACE_END
diff --git a/gui/basewindow.h b/gui/basewindow.h
index 1184fa80..a25a2854 100644
--- a/gui/basewindow.h
+++ b/gui/basewindow.h
@@ -37,6 +37,7 @@ NEXTPNR_NAMESPACE_BEGIN
class PythonTab;
class DesignWidget;
+class FPGAViewWidget;
class BaseMainWindow : public QMainWindow
{
@@ -49,6 +50,7 @@ class BaseMainWindow : public QMainWindow
protected:
void createMenusAndBars();
+ void createGraphicsBar();
protected Q_SLOTS:
void writeInfo(std::string text);
@@ -70,12 +72,14 @@ class BaseMainWindow : public QMainWindow
QMenuBar *menuBar;
QToolBar *mainToolBar;
+ QToolBar *graphicsToolBar;
QStatusBar *statusBar;
QAction *actionNew;
QAction *actionOpen;
QAction *actionSave;
QProgressBar *progressBar;
DesignWidget *designview;
+ FPGAViewWidget *fpgaView;
};
NEXTPNR_NAMESPACE_END
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index 15f37ce0..e08667f6 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -580,21 +580,32 @@ void FPGAViewWidget::wheelEvent(QWheelEvent *event)
{
QPoint degree = event->angleDelta() / 8;
- if (!degree.isNull()) {
-
- if (zoom_ < zoomNear_) {
- zoom_ = zoomNear_;
- } else if (zoom_ < zoomLvl1_) {
- zoom_ -= degree.y() / 10.0;
- } else if (zoom_ < zoomLvl2_) {
- zoom_ -= degree.y() / 5.0;
- } else if (zoom_ < zoomFar_) {
- zoom_ -= degree.y();
- } else {
- zoom_ = zoomFar_;
- }
- update();
+ if (!degree.isNull())
+ zoom(degree.y());
+}
+
+void FPGAViewWidget::zoom(int level)
+{
+ if (zoom_ < zoomNear_) {
+ zoom_ = zoomNear_;
+ } else if (zoom_ < zoomLvl1_) {
+ zoom_ -= level / 10.0;
+ } else if (zoom_ < zoomLvl2_) {
+ zoom_ -= level / 5.0;
+ } else if (zoom_ < zoomFar_) {
+ zoom_ -= level;
+ } else {
+ zoom_ = zoomFar_;
}
+ update();
}
+void FPGAViewWidget::zoom_in() { zoom(10); }
+
+void FPGAViewWidget::zoom_out() { zoom(-10); }
+
+void FPGAViewWidget::zoom_selected() {}
+
+void FPGAViewWidget::zoom_outbound() {}
+
NEXTPNR_NAMESPACE_END
diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h
index b87c5d0a..636d5672 100644
--- a/gui/fpgaviewwidget.h
+++ b/gui/fpgaviewwidget.h
@@ -292,9 +292,13 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void onSelectedArchItem(std::vector<DecalXY> decals);
void onHighlightGroupChanged(std::vector<DecalXY> decals, int group);
void pokeRenderer(void);
-
+ void zoom_in();
+ void zoom_out();
+ void zoom_selected();
+ void zoom_outbound();
private:
void renderLines(void);
+ void zoom(int level);
QPoint lastPos_;
LineShader lineShader_;
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index 810a98ae..f06971b6 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -159,6 +159,8 @@ void MainWindow::createMenu()
taskToolBar->addAction(actionPlay);
taskToolBar->addAction(actionPause);
taskToolBar->addAction(actionStop);
+
+ createGraphicsBar();
}
#if defined(_MSC_VER)
diff --git a/gui/resources/shape_handles.png b/gui/resources/shape_handles.png
new file mode 100644
index 00000000..ce27fe3a
--- /dev/null
+++ b/gui/resources/shape_handles.png
Binary files differ
diff --git a/gui/resources/shape_square.png b/gui/resources/shape_square.png
new file mode 100644
index 00000000..33af0460
--- /dev/null
+++ b/gui/resources/shape_square.png
Binary files differ
diff --git a/gui/resources/zoom_in.png b/gui/resources/zoom_in.png
new file mode 100644
index 00000000..cdf0a52f
--- /dev/null
+++ b/gui/resources/zoom_in.png
Binary files differ
diff --git a/gui/resources/zoom_out.png b/gui/resources/zoom_out.png
new file mode 100644
index 00000000..07bf98a7
--- /dev/null
+++ b/gui/resources/zoom_out.png
Binary files differ