diff --git a/DestinationGLCanvas.cpp b/DestinationGLCanvas.cpp index 119c18a..58a44f3 100644 --- a/DestinationGLCanvas.cpp +++ b/DestinationGLCanvas.cpp @@ -93,6 +93,7 @@ void DestinationGLCanvas::doDraw(QPainter* painter) painter->drawLine(0, cursorPosition.y(), geo.width(), cursorPosition.y()); } } + } void DestinationGLCanvas::_drawTestSignal(QPainter* painter) @@ -145,8 +146,8 @@ bool DestinationGLCanvas::eventFilter(QObject *target, QEvent *event) if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); + setActiveVertexIndex(getMainWindow()->getOutputWindow()->getCanvas()->getActiveVertexIndex()); MapperGLCanvas::keyPressEvent(keyEvent); - qDebug() << "Test:" << keyEvent << endl; return true; } else diff --git a/DestinationGLCanvas.h b/DestinationGLCanvas.h index 4aca402..4539e13 100644 --- a/DestinationGLCanvas.h +++ b/DestinationGLCanvas.h @@ -51,6 +51,8 @@ private: protected: // overriden from QGlWidget: virtual void resizeGL(int width, int height); + + // Event Filter bool eventFilter(QObject *target, QEvent *event); }; diff --git a/MainWindow.h b/MainWindow.h index 16b3e3c..7b79928 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -358,6 +358,7 @@ public: Mapper::ptr getMapperByMappingId(uint id) { return mappers[id]; } uid getCurrentPaintId() const { return currentPaintId; } uid getCurrentMappingId() const { return currentMappingId; } + OutputGLWindow* getOutputWindow() const { return outputWindow; } bool hasCurrentPaint() const { return _hasCurrentPaint; } bool hasCurrentMapping() const { return _hasCurrentMapping; } void setCurrentPaint(int uid); diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index 07cc201..72346e9 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -125,6 +125,7 @@ void MapperGLCanvas::mousePressEvent(QMouseEvent* event) { _activeVertex = i; minDistance = dist; + _mousePressedOnVertex = true; mousePressedOnSomething = true; } @@ -219,7 +220,7 @@ void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event) shape->translate(event->x() - prevMousePosition.x(), event->y() - prevMousePosition.y()); update(); emit shapeChanged(getCurrentShape()); - } + } else _shapeFirstGrab = false; } @@ -320,7 +321,7 @@ void MapperGLCanvas::keyPressEvent(QKeyEvent* event) // emit quadChanged(); } -void MapperGLCanvas::paintEvent(QPaintEvent* /* event */) +void MapperGLCanvas::paintEvent(QPaintEvent* ) { makeCurrent(); diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h index d13a219..ca8ef24 100644 --- a/MapperGLCanvas.h +++ b/MapperGLCanvas.h @@ -79,6 +79,9 @@ public: /// Returns the currently active (ie. selected) vertex, or NO_VERTEX if none is currently active. int getActiveVertexIndex() const { return _activeVertex; } + /// Set the currently active vertex + void setActiveVertexIndex(int activeVertex) { _activeVertex = activeVertex; } + protected: void initializeGL(); void resizeGL(int width, int height);