added buttons for new zoom operations

This commit is contained in:
Miodrag Milanovic 2018-07-26 13:21:46 +02:00
parent c9b9d9b227
commit 4587b8c000
10 changed files with 68 additions and 18 deletions

View File

@ -10,5 +10,9 @@
<file>resources/resultset_next.png</file> <file>resources/resultset_next.png</file>
<file>resources/resultset_last.png</file> <file>resources/resultset_last.png</file>
<file>resources/cross.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> </qresource>
</RCC> </RCC>

View File

@ -25,7 +25,6 @@
#include <QSplitter> #include <QSplitter>
#include "designwidget.h" #include "designwidget.h"
#include "fpgaviewwidget.h" #include "fpgaviewwidget.h"
#include "jsonparse.h"
#include "log.h" #include "log.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "pythontab.h" #include "pythontab.h"
@ -76,7 +75,7 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
centralTabWidget->setTabsClosable(true); centralTabWidget->setTabsClosable(true);
connect(centralTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(centralTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
FPGAViewWidget *fpgaView = new FPGAViewWidget(); fpgaView = new FPGAViewWidget();
centralTabWidget->addTab(fpgaView, "Graphics"); centralTabWidget->addTab(fpgaView, "Graphics");
centralTabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0); centralTabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0);
@ -163,4 +162,30 @@ void BaseMainWindow::createMenusAndBars()
mainToolBar->addAction(actionSave); 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 NEXTPNR_NAMESPACE_END

View File

@ -37,6 +37,7 @@ NEXTPNR_NAMESPACE_BEGIN
class PythonTab; class PythonTab;
class DesignWidget; class DesignWidget;
class FPGAViewWidget;
class BaseMainWindow : public QMainWindow class BaseMainWindow : public QMainWindow
{ {
@ -49,6 +50,7 @@ class BaseMainWindow : public QMainWindow
protected: protected:
void createMenusAndBars(); void createMenusAndBars();
void createGraphicsBar();
protected Q_SLOTS: protected Q_SLOTS:
void writeInfo(std::string text); void writeInfo(std::string text);
@ -70,12 +72,14 @@ class BaseMainWindow : public QMainWindow
QMenuBar *menuBar; QMenuBar *menuBar;
QToolBar *mainToolBar; QToolBar *mainToolBar;
QToolBar *graphicsToolBar;
QStatusBar *statusBar; QStatusBar *statusBar;
QAction *actionNew; QAction *actionNew;
QAction *actionOpen; QAction *actionOpen;
QAction *actionSave; QAction *actionSave;
QProgressBar *progressBar; QProgressBar *progressBar;
DesignWidget *designview; DesignWidget *designview;
FPGAViewWidget *fpgaView;
}; };
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -580,21 +580,32 @@ void FPGAViewWidget::wheelEvent(QWheelEvent *event)
{ {
QPoint degree = event->angleDelta() / 8; QPoint degree = event->angleDelta() / 8;
if (!degree.isNull()) { if (!degree.isNull())
zoom(degree.y());
}
void FPGAViewWidget::zoom(int level)
{
if (zoom_ < zoomNear_) { if (zoom_ < zoomNear_) {
zoom_ = zoomNear_; zoom_ = zoomNear_;
} else if (zoom_ < zoomLvl1_) { } else if (zoom_ < zoomLvl1_) {
zoom_ -= degree.y() / 10.0; zoom_ -= level / 10.0;
} else if (zoom_ < zoomLvl2_) { } else if (zoom_ < zoomLvl2_) {
zoom_ -= degree.y() / 5.0; zoom_ -= level / 5.0;
} else if (zoom_ < zoomFar_) { } else if (zoom_ < zoomFar_) {
zoom_ -= degree.y(); zoom_ -= level;
} else { } else {
zoom_ = zoomFar_; zoom_ = zoomFar_;
} }
update(); update();
}
} }
void FPGAViewWidget::zoom_in() { zoom(10); }
void FPGAViewWidget::zoom_out() { zoom(-10); }
void FPGAViewWidget::zoom_selected() {}
void FPGAViewWidget::zoom_outbound() {}
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -292,9 +292,13 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void onSelectedArchItem(std::vector<DecalXY> decals); void onSelectedArchItem(std::vector<DecalXY> decals);
void onHighlightGroupChanged(std::vector<DecalXY> decals, int group); void onHighlightGroupChanged(std::vector<DecalXY> decals, int group);
void pokeRenderer(void); void pokeRenderer(void);
void zoom_in();
void zoom_out();
void zoom_selected();
void zoom_outbound();
private: private:
void renderLines(void); void renderLines(void);
void zoom(int level);
QPoint lastPos_; QPoint lastPos_;
LineShader lineShader_; LineShader lineShader_;

View File

@ -159,6 +159,8 @@ void MainWindow::createMenu()
taskToolBar->addAction(actionPlay); taskToolBar->addAction(actionPlay);
taskToolBar->addAction(actionPause); taskToolBar->addAction(actionPause);
taskToolBar->addAction(actionStop); taskToolBar->addAction(actionStop);
createGraphicsBar();
} }
#if defined(_MSC_VER) #if defined(_MSC_VER)

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

BIN
gui/resources/zoom_in.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

BIN
gui/resources/zoom_out.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B