From ffe6ff76b874a9dd917694b65108169348f82d2e Mon Sep 17 00:00:00 2001 From: Tats Date: Sat, 18 Jul 2015 13:12:56 -0600 Subject: [PATCH] Bug fix: update of control point positions in property browser goes both ways. --- Commands.cpp | 4 ++-- Mapper.cpp | 9 +++++++++ Mapper.h | 2 +- MapperGLCanvas.cpp | 6 ++++++ MapperGLCanvas.h | 3 +++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Commands.cpp b/Commands.cpp index ea1ec38..d97bc4a 100644 --- a/Commands.cpp +++ b/Commands.cpp @@ -43,14 +43,14 @@ void MoveVertexCommand::undo() { _shape.toStrongRef()->copyFrom(*_originalShape); _canvas->update(); -// emit m_mapperGLCanvas->shapeChanged(m_mapperGLCanvas->getCurrentShape()); + _canvas->currentShapeWasChanged(); } void MoveVertexCommand::redo() { _shape.toStrongRef()->setVertex(_movedVertex, _vertexPosition); _canvas->update(); -// emit m_mapperGLCanvas->shapeChanged(m_mapperGLCanvas->getCurrentShape()); + _canvas->currentShapeWasChanged(); } bool MoveVertexCommand::mergeWith(const QUndoCommand* other) diff --git a/Mapper.cpp b/Mapper.cpp index 778767c..7964cf0 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -692,6 +692,14 @@ void Mapper::setValue(QtProperty* property, const QVariant& value) } } +void Mapper::updateShape(MShape* shape) +{ + if (shape == _mapping->getShape().data()) + { + _updateShapeProperty(_outputItem, shape); + } +} + void Mapper::_buildShapeProperty(QtProperty* shapeItem, MShape* shape) { for (int i=0; inVertices(); i++) @@ -731,6 +739,7 @@ ColorMapper::ColorMapper(Mapping::ptr mapping) Q_CHECK_PTR(color); } + //MeshColorMapper::MeshColorMapper(Mapping::ptr mapping) // : ColorMapper(mapping) { // // Add mesh sub property. diff --git a/Mapper.h b/Mapper.h index e8ed97a..65d7abe 100644 --- a/Mapper.h +++ b/Mapper.h @@ -324,7 +324,7 @@ public: public slots: virtual void setValue(QtProperty* property, const QVariant& value); - virtual void updateShape(MShape* shape) { Q_UNUSED(shape); } + virtual void updateShape(MShape* shape); signals: void valueChanged(); diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index 9e602ad..db201e1 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -93,6 +93,12 @@ void MapperGLCanvas::drawForeground(QPainter *painter , const QRectF &rect) } } +void MapperGLCanvas::currentShapeWasChanged() +{ + emit shapeChanged(getCurrentShape().data()); +} + + // void MapperGLCanvas::mousePressEvent(QMouseEvent* event) { diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h index f21ace4..e25d29e 100644 --- a/MapperGLCanvas.h +++ b/MapperGLCanvas.h @@ -85,6 +85,9 @@ public: qreal getZoomFactor() const { return qBound(qPow(MM::ZOOM_FACTOR, _zoomLevel), MM::ZOOM_MIN, MM::ZOOM_MAX); } + /// This function needs to be called after a shape inside the canvas has been changed for appropriate signals to be activated. + void currentShapeWasChanged(); + protected: // void initializeGL(); // void resizeGL(int width, int height);