New feature: menu option toggle sticky vertices

This commit is contained in:
Alexandre Quessy
2014-10-14 01:48:00 -04:00
parent 39ee4903c7
commit 1b73d45a89
4 changed files with 28 additions and 2 deletions
+15
View File
@@ -1143,6 +1143,19 @@ void MainWindow::createActions()
connect(displayCanvasControls, SIGNAL(toggled(bool)), sourceCanvas, SLOT(enableDisplayControls(bool)));
connect(displayCanvasControls, SIGNAL(toggled(bool)), destinationCanvas, SLOT(enableDisplayControls(bool)));
connect(displayCanvasControls, SIGNAL(toggled(bool)), outputWindow->getCanvas(), SLOT(enableDisplayControls(bool)));
// Toggle sticky vertices
stickyVertices = new QAction(tr("&Sticky vertices"), this);
// stickyVertices->setShortcut(tr("Ctrl+E"));
stickyVertices->setIcon(QIcon(":/control-points"));
stickyVertices->setStatusTip(tr("Enable sticky vertices"));
stickyVertices->setIconVisibleInMenu(false);
stickyVertices->setCheckable(true);
stickyVertices->setChecked(true);
// Manage sticky vertices
connect(stickyVertices, SIGNAL(toggled(bool)), sourceCanvas, SLOT(enableStickyVertices(bool)));
connect(stickyVertices, SIGNAL(toggled(bool)), destinationCanvas, SLOT(enableStickyVertices(bool)));
connect(stickyVertices, SIGNAL(toggled(bool)), outputWindow->getCanvas(), SLOT(enableStickyVertices(bool)));
}
void MainWindow::createMenus()
@@ -1181,6 +1194,7 @@ void MainWindow::createMenus()
viewMenu->addAction(displayOutputWindow);
viewMenu->addAction(outputWindowFullScreen);
viewMenu->addAction(displayCanvasControls);
viewMenu->addAction(stickyVertices);
// Run.
runMenu = menuBar->addMenu(tr("&Run"));
@@ -1242,6 +1256,7 @@ void MainWindow::createToolBars()
mainToolBar->addAction(displayOutputWindow);
mainToolBar->addAction(outputWindowFullScreen);
mainToolBar->addAction(displayCanvasControls);
mainToolBar->addAction(stickyVertices);
runToolBar = addToolBar(tr("&Run"));
runToolBar->setIconSize(QSize(MM::TOP_TOOLBAR_ICON_SIZE, MM::TOP_TOOLBAR_ICON_SIZE));
+1
View File
@@ -249,6 +249,7 @@ private:
QAction *displayOutputWindow;
QAction *outputWindowFullScreen;
QAction *displayCanvasControls;
QAction *stickyVertices;
// Widgets and layout.
+9 -2
View File
@@ -29,7 +29,8 @@ MapperGLCanvas::MapperGLCanvas(MainWindow* mainWindow, QWidget* parent, const QG
_activeVertex(NO_VERTEX),
_shapeGrabbed(false), // comment out?
_shapeFirstGrab(false), // comment out?
_displayControls(true)
_displayControls(true),
_stickyVertices(true)
{
}
@@ -156,7 +157,8 @@ void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event)
p.setY(event->y());
// Stick to vertices.
glueVertex(shape, &p);
if (stickyVertices())
glueVertex(shape, &p);
shape->setVertex(_activeVertex, p);
update();
@@ -254,6 +256,11 @@ void MapperGLCanvas::enableDisplayControls(bool display)
updateCanvas();
}
void MapperGLCanvas::enableStickyVertices(bool value)
{
_stickyVertices = value;
}
/* Stick vertex p of Shape orig to another Shape's vertex, if the 2 vertices are
* close enough. The distance per coordinate is currently set in dist_stick
* variable. Perhaps the sticky-sensitivity should be configurable through GUI */
+3
View File
@@ -52,6 +52,7 @@ public:
MainWindow* getMainWindow() const { return _mainWindow; }
bool displayControls() const { return _displayControls; }
bool stickyVertices() const { return _stickyVertices; }
protected:
void initializeGL();
@@ -76,6 +77,7 @@ private:
bool _shapeGrabbed;
bool _shapeFirstGrab;
bool _displayControls;
bool _stickyVertices;
signals:
void shapeChanged(Shape*);
@@ -84,6 +86,7 @@ signals:
public slots:
void updateCanvas();
void enableDisplayControls(bool display);
void enableStickyVertices(bool display);
void deselectAll();
public: