From 4d3694fe288a06de70ffd8315e6b903e3315e315 Mon Sep 17 00:00:00 2001 From: Tats Date: Thu, 10 Apr 2014 18:27:40 -0400 Subject: [PATCH] Added an option to toggle the display of shape control points --- DestinationGLCanvas.cpp | 3 ++- MainWindow.cpp | 12 ++++++++++++ MainWindow.h | 1 + MapperGLCanvas.cpp | 9 ++++++++- MapperGLCanvas.h | 3 +++ SourceGLCanvas.cpp | 3 ++- 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/DestinationGLCanvas.cpp b/DestinationGLCanvas.cpp index 6b5117e..e2f7224 100644 --- a/DestinationGLCanvas.cpp +++ b/DestinationGLCanvas.cpp @@ -90,7 +90,8 @@ void DestinationGLCanvas::doDraw(QPainter* painter) } // Draw the controls of current mapping. - if (getMainWindow()->hasCurrentMapping() && + if (displayControls() && + getMainWindow()->hasCurrentMapping() && getCurrentShape() != NULL) { getMainWindow()->getMapperByMappingId(getMainWindow()->getCurrentMappingId())->drawControls(painter); diff --git a/MainWindow.cpp b/MainWindow.cpp index f6533b9..0d9ff9c 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -891,6 +891,17 @@ void MainWindow::createActions() connect(displayOutputWindow, SIGNAL(toggled(bool)), outputWindow, SLOT(setVisible(bool))); // When closing the GL output window, uncheck the action in menu. connect(outputWindow, SIGNAL(closed()), displayOutputWindow, SLOT(toggle())); + + // Toggle display of canvas controls. + displayCanvasControls = new QAction(tr("&Display canvas controls"), this); +// displayCanvasControls->setShortcut(tr("Ctrl+E")); + displayCanvasControls->setStatusTip(tr("Display canvas controls")); + displayCanvasControls->setCheckable(true); + displayCanvasControls->setChecked(true); + // Manage show/hide of canvas controls. + 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))); } void MainWindow::createMenus() @@ -917,6 +928,7 @@ void MainWindow::createMenus() // View. viewMenu = menuBar()->addMenu(tr("&View")); viewMenu->addAction(displayOutputWindow); + viewMenu->addAction(displayCanvasControls); // selectSubMenu = editMenu->addMenu(tr("&Select")); // selectSubMenu->addAction(selectRowAction); diff --git a/MainWindow.h b/MainWindow.h index 56be2cf..93bbf10 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -224,6 +224,7 @@ private: QAction *addEllipseAction; QAction *displayOutputWindow; + QAction *displayCanvasControls; // Widgets and layout. diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index 33f35ea..e2b4495 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -23,7 +23,7 @@ #include "MainWindow.h" MapperGLCanvas::MapperGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget * shareWidget) - : QGLWidget(parent, shareWidget), _mainWindow(mainWindow), _mousepressed(false), _active_vertex(NO_VERTEX) + : QGLWidget(parent, shareWidget), _mainWindow(mainWindow), _mousepressed(false), _active_vertex(NO_VERTEX), _displayControls(true) { } @@ -279,6 +279,13 @@ void MapperGLCanvas::updateCanvas() update(); } +void MapperGLCanvas::enableDisplayControls(bool display) +{ + _displayControls = display; + qDebug() << "Toggle display to " << display << endl; + updateCanvas(); +} + /* 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 */ diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h index 3110ea6..50fa8f0 100644 --- a/MapperGLCanvas.h +++ b/MapperGLCanvas.h @@ -51,6 +51,7 @@ public: void glueVertex(Shape *, QPointF *); MainWindow* getMainWindow() const { return _mainWindow; } + bool displayControls() const { return _displayControls; } protected: void initializeGL(); @@ -74,6 +75,7 @@ private: int _active_vertex; bool _shapegrabbed; bool _shapefirstgrab; + bool _displayControls; signals: void shapeChanged(Shape*); @@ -81,6 +83,7 @@ signals: public slots: void updateCanvas(); + void enableDisplayControls(bool display); void deselectAll(); public: diff --git a/SourceGLCanvas.cpp b/SourceGLCanvas.cpp index e4f49db..1ac96e3 100644 --- a/SourceGLCanvas.cpp +++ b/SourceGLCanvas.cpp @@ -163,7 +163,8 @@ void SourceGLCanvas::_drawTexture(QPainter* painter, Paint::ptr paint, QMap inputShape = std::tr1::static_pointer_cast(textureMapping->getInputShape()); Q_CHECK_PTR(inputShape); - if (it.key() == getMainWindow()->getCurrentMappingId()) + if (displayControls() && + it.key() == getMainWindow()->getCurrentMappingId()) { Mapper::ptr mapper = getMainWindow()->getMapperByMappingId(it.key()); Q_CHECK_PTR(mapper);