diff --git a/DestinationGLCanvas.cpp b/DestinationGLCanvas.cpp index 1116d5f..43b1e96 100644 --- a/DestinationGLCanvas.cpp +++ b/DestinationGLCanvas.cpp @@ -27,7 +27,7 @@ DestinationGLCanvas::DestinationGLCanvas(MainWindow* mainWindow, QWidget* parent { } -Shape* DestinationGLCanvas::getShapeFromMappingId(uid mappingId) +MShape* DestinationGLCanvas::getShapeFromMappingId(uid mappingId) { if (mappingId == NULL_UID) return NULL; diff --git a/DestinationGLCanvas.h b/DestinationGLCanvas.h index bbd5d45..4d99c09 100644 --- a/DestinationGLCanvas.h +++ b/DestinationGLCanvas.h @@ -34,7 +34,7 @@ public: DestinationGLCanvas(MainWindow* mainWindow, QWidget* parent = 0, const QGLWidget * shareWidget = 0); // virtual ~DestinationGLCanvas(); - virtual Shape* getShapeFromMappingId(uid mappingId); + virtual MShape* getShapeFromMappingId(uid mappingId); void setDisplayCrosshair(bool displayCrosshair) { _displayCrosshair = displayCrosshair; diff --git a/MainWindow.cpp b/MainWindow.cpp index de0d506..d405ddc 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -409,7 +409,7 @@ void MainWindow::addMesh() Mapping* mappingPtr; if (paint->getType() == "color") { - Shape::ptr outputQuad = Shape::ptr(Util::createQuadForColor(sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr outputQuad = MShape::ptr(Util::createQuadForColor(sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new ColorMapping(paint, outputQuad); } else @@ -417,8 +417,8 @@ void MainWindow::addMesh() std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(paint); Q_CHECK_PTR(texture); - Shape::ptr outputQuad = Shape::ptr(Util::createMeshForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); - Shape::ptr inputQuad = Shape::ptr(Util::createMeshForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr outputQuad = MShape::ptr(Util::createMeshForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr inputQuad = MShape::ptr(Util::createMeshForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new TextureMapping(paint, outputQuad, inputQuad); } @@ -442,7 +442,7 @@ void MainWindow::addTriangle() Mapping* mappingPtr; if (paint->getType() == "color") { - Shape::ptr outputTriangle = Shape::ptr(Util::createTriangleForColor(sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr outputTriangle = MShape::ptr(Util::createTriangleForColor(sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new ColorMapping(paint, outputTriangle); } else @@ -450,8 +450,8 @@ void MainWindow::addTriangle() std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(paint); Q_CHECK_PTR(texture); - Shape::ptr outputTriangle = Shape::ptr(Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); - Shape::ptr inputTriangle = Shape::ptr(Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr outputTriangle = MShape::ptr(Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr inputTriangle = MShape::ptr(Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new TextureMapping(paint, inputTriangle, outputTriangle); } @@ -475,7 +475,7 @@ void MainWindow::addEllipse() Mapping* mappingPtr; if (paint->getType() == "color") { - Shape::ptr outputEllipse = Shape::ptr(Util::createEllipseForColor(sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr outputEllipse = MShape::ptr(Util::createEllipseForColor(sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new ColorMapping(paint, outputEllipse); } else @@ -483,8 +483,8 @@ void MainWindow::addEllipse() std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(paint); Q_CHECK_PTR(texture); - Shape::ptr outputEllipse = Shape::ptr(Util::createEllipseForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); - Shape::ptr inputEllipse = Shape::ptr(Util::createEllipseForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr outputEllipse = MShape::ptr(Util::createEllipseForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr inputEllipse = MShape::ptr(Util::createEllipseForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new TextureMapping(paint, inputEllipse, outputEllipse); } @@ -722,8 +722,8 @@ uid MainWindow::createMeshTextureMapping(uid mappingId, qDebug() << nVertices << " vs " << nColumns << "x" << nRows << " vs " << src.size() << " " << dst.size() << endl; Q_ASSERT(src.size() == nVertices && dst.size() == nVertices); - Shape::ptr inputMesh( new Mesh(src, nColumns, nRows)); - Shape::ptr outputMesh(new Mesh(dst, nColumns, nRows)); + MShape::ptr inputMesh( new Mesh(src, nColumns, nRows)); + MShape::ptr outputMesh(new Mesh(dst, nColumns, nRows)); // Add it to the manager. Mapping::ptr mapping(new TextureMapping(paint, outputMesh, inputMesh, mappingId)); @@ -752,8 +752,8 @@ uid MainWindow::createTriangleTextureMapping(uid mappingId, Paint::ptr paint = mappingManager->getPaintById(paintId); Q_ASSERT(src.size() == 3 && dst.size() == 3); - Shape::ptr inputTriangle( new Triangle(src[0], src[1], src[2])); - Shape::ptr outputTriangle(new Triangle(dst[0], dst[1], dst[2])); + MShape::ptr inputTriangle( new Triangle(src[0], src[1], src[2])); + MShape::ptr outputTriangle(new Triangle(dst[0], dst[1], dst[2])); // Add it to the manager. Mapping::ptr mapping(new TextureMapping(paint, outputTriangle, inputTriangle, mappingId)); @@ -782,8 +782,8 @@ uid MainWindow::createEllipseTextureMapping(uid mappingId, Paint::ptr paint = mappingManager->getPaintById(paintId); Q_ASSERT(src.size() == 5 && dst.size() == 5); - Shape::ptr inputEllipse( new Ellipse(src[0], src[1], src[2], src[3], src[4])); - Shape::ptr outputEllipse(new Ellipse(dst[0], dst[1], dst[2], dst[3], dst[4])); + MShape::ptr inputEllipse( new Ellipse(src[0], src[1], src[2], src[3], src[4])); + MShape::ptr outputEllipse(new Ellipse(dst[0], dst[1], dst[2], dst[3], dst[4])); // Add it to the manager. Mapping::ptr mapping(new TextureMapping(paint, outputEllipse, inputEllipse, mappingId)); @@ -812,7 +812,7 @@ uid MainWindow::createQuadColorMapping(uid mappingId, Paint::ptr paint = mappingManager->getPaintById(paintId); Q_ASSERT(dst.size() == 4); - Shape::ptr outputQuad(new Quad(dst[0], dst[1], dst[2], dst[3])); + MShape::ptr outputQuad(new Quad(dst[0], dst[1], dst[2], dst[3])); // Add it to the manager. Mapping::ptr mapping(new ColorMapping(paint, outputQuad, mappingId)); @@ -841,7 +841,7 @@ uid MainWindow::createTriangleColorMapping(uid mappingId, Paint::ptr paint = mappingManager->getPaintById(paintId); Q_ASSERT(dst.size() == 3); - Shape::ptr outputTriangle(new Triangle(dst[0], dst[1], dst[2])); + MShape::ptr outputTriangle(new Triangle(dst[0], dst[1], dst[2])); // Add it to the manager. Mapping::ptr mapping(new ColorMapping(paint, outputTriangle, mappingId)); @@ -870,7 +870,7 @@ uid MainWindow::createEllipseColorMapping(uid mappingId, Paint::ptr paint = mappingManager->getPaintById(paintId); Q_ASSERT(dst.size() == 4); - Shape::ptr outputEllipse(new Ellipse(dst[0], dst[1], dst[2], dst[3])); + MShape::ptr outputEllipse(new Ellipse(dst[0], dst[1], dst[2], dst[3])); // Add it to the manager. Mapping::ptr mapping(new ColorMapping(paint, outputEllipse, mappingId)); diff --git a/Mapper.cpp b/Mapper.cpp index 8713fd9..c9766c5 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -65,11 +65,11 @@ QWidget* Mapper::getPropertiesEditor() void Mapper::setValue(QtProperty* property, const QVariant& value) { - std::map >::iterator it = _propertyToVertex.find(property); + std::map >::iterator it = _propertyToVertex.find(property); if (it != _propertyToVertex.end()) { const QPointF& p = value.toPointF(); - Shape* shape = it->second.first; + MShape* shape = it->second.first; int v = it->second.second; if (shape->getVertex(v) != p) { @@ -79,7 +79,7 @@ void Mapper::setValue(QtProperty* property, const QVariant& value) } } -void Mapper::_buildShapeProperty(QtProperty* shapeItem, Shape* shape) +void Mapper::_buildShapeProperty(QtProperty* shapeItem, MShape* shape) { for (int i=0; inVertices(); i++) { @@ -96,7 +96,7 @@ void Mapper::_buildShapeProperty(QtProperty* shapeItem, Shape* shape) } -void Mapper::_updateShapeProperty(QtProperty* shapeItem, Shape* shape) +void Mapper::_updateShapeProperty(QtProperty* shapeItem, MShape* shape) { QList pointItems = shapeItem->subProperties(); for (int i=0; inVertices(); i++) @@ -233,7 +233,7 @@ TextureMapper::TextureMapper(std::tr1::shared_ptr mapping) texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); Q_CHECK_PTR(texture); - inputShape = std::tr1::static_pointer_cast(textureMapping->getInputShape()); + inputShape = std::tr1::static_pointer_cast(textureMapping->getInputShape()); Q_CHECK_PTR(inputShape); // Input shape. @@ -282,7 +282,7 @@ void TextureMapper::drawInput(QPainter* painter) _postDraw(painter); } -void TextureMapper::updateShape(Shape* shape) +void TextureMapper::updateShape(MShape* shape) { std::tr1::shared_ptr textureMapping = std::tr1::static_pointer_cast(_mapping); Q_CHECK_PTR(textureMapping); @@ -290,8 +290,8 @@ void TextureMapper::updateShape(Shape* shape) std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); Q_CHECK_PTR(texture); - Shape* inputShape = textureMapping->getInputShape().get(); - Shape* outputShape = textureMapping->getShape().get(); + MShape* inputShape = textureMapping->getInputShape().get(); + MShape* outputShape = textureMapping->getShape().get(); if (shape == inputShape) { _updateShapeProperty(_inputItem, inputShape); diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index e9d7d84..b7ee0e3 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -351,12 +351,12 @@ void MapperGLCanvas::enableStickyVertices(bool 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 */ -void MapperGLCanvas::glueVertex(Shape *orig, QPointF *p) +void MapperGLCanvas::glueVertex(MShape *orig, QPointF *p) { MappingManager manager = getMainWindow()->getMappingManager(); for (int i = 0; i < manager.nMappings(); i++) { - Shape *shape = getShapeFromMappingId(manager.getMapping(i)->getId()); + MShape *shape = getShapeFromMappingId(manager.getMapping(i)->getId()); if (shape && shape != orig) { for (int vertex = 0; vertex < shape->nVertices(); vertex++) diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h index a1a1704..93a3191 100644 --- a/MapperGLCanvas.h +++ b/MapperGLCanvas.h @@ -45,13 +45,13 @@ public: virtual ~MapperGLCanvas() {} /// Returns shape associated with mapping id. - virtual Shape* getShapeFromMappingId(uid mappingId) = 0; + virtual MShape* getShapeFromMappingId(uid mappingId) = 0; // QSize sizeHint() const; // QSize minimumSizeHint() const; /// Returns current shape. - Shape* getCurrentShape(); +// Shape* getCurrentShape(); /** * Stick vertex p of Shape orig to another Shape's vertex, if the 2 vertices are @@ -59,7 +59,7 @@ public: * variable. */ // TODO: Perhaps the sticky-sensitivity should be configurable through GUI - void glueVertex(Shape *, QPointF *); + void glueVertex(MShape *, QPointF *); /// Returns pointer to main window. MainWindow* getMainWindow() const { return _mainWindow; } @@ -133,7 +133,7 @@ private: bool _stickyVertices; signals: - void shapeChanged(Shape*); + void shapeChanged(MShape*); void imageChanged(); public slots: diff --git a/Mapping.cpp b/Mapping.cpp index c4d1051..e1c6301 100644 --- a/Mapping.cpp +++ b/Mapping.cpp @@ -22,7 +22,7 @@ UidAllocator Mapping::allocator; -Mapping::Mapping(Paint::ptr paint, Shape::ptr shape, uid id) +Mapping::Mapping(Paint::ptr paint, MShape::ptr shape, uid id) : _paint(paint), _shape(shape), _isLocked(false), _isSolo(false), _isVisible(true), _opacity(1.0f) { diff --git a/Mapping.h b/Mapping.h index 25c2cd0..8a0d013 100644 --- a/Mapping.h +++ b/Mapping.h @@ -46,7 +46,7 @@ protected: Paint::ptr _paint; /// The output Shape instance. - Shape::ptr _shape; + MShape::ptr _shape; private: static UidAllocator allocator; @@ -60,7 +60,7 @@ private: protected: /// Constructor. - Mapping(Paint::ptr paint, Shape::ptr shape, uid id=NULL_UID); + Mapping(Paint::ptr paint, MShape::ptr shape, uid id=NULL_UID); public: typedef std::tr1::shared_ptr ptr; @@ -85,13 +85,13 @@ public: Paint::ptr getPaint() const { return _paint; } /// Returns the (output) shape. - Shape::ptr getShape() const { return _shape; } + MShape::ptr getShape() const { return _shape; } /// Returns true iff the mapping possesses an input (source) shape. virtual bool hasInputShape() const { return false; } /// Returns the input (source) shape (if this mapping has one) or a null pointer if not. - virtual Shape::ptr getInputShape() const { return Shape::ptr(); } + virtual MShape::ptr getInputShape() const { return MShape::ptr(); } uid getId() const { return _id; } @@ -121,7 +121,7 @@ public: class ColorMapping : public Mapping { public: - ColorMapping(Paint::ptr paint, Shape::ptr shape, + ColorMapping(Paint::ptr paint, MShape::ptr shape, uid id=NULL_UID) : Mapping(paint, shape, id) {} @@ -138,12 +138,12 @@ public: class TextureMapping : public Mapping { private: - Shape::ptr _inputShape; + MShape::ptr _inputShape; public: TextureMapping(Paint::ptr paint, - Shape::ptr shape, - Shape::ptr inputShape, uid id=NULL_UID) + MShape::ptr shape, + MShape::ptr inputShape, uid id=NULL_UID) : Mapping(paint, shape, id), _inputShape(inputShape) { @@ -162,7 +162,7 @@ public: public: virtual bool hasInputShape() const { return true; } - virtual Shape::ptr getInputShape() const { return _inputShape; } + virtual MShape::ptr getInputShape() const { return _inputShape; } }; #endif /* MAPPING_H_ */ diff --git a/ProjectWriter.cpp b/ProjectWriter.cpp index 5dcaeca..b3a06ab 100644 --- a/ProjectWriter.cpp +++ b/ProjectWriter.cpp @@ -117,7 +117,7 @@ void ProjectWriter::writeItem(Paint *item) qDebug() << "Unknown type, cannot save: " << item->getType() << endl; } -void ProjectWriter::writeShapeVertices(Shape *shape) +void ProjectWriter::writeShapeVertices(MShape *shape) { if (shape->getType() == "mesh") { Mesh* mesh = (Mesh*) shape; @@ -150,7 +150,7 @@ void ProjectWriter::writeItem(Mapping *item) _xml.writeAttribute("solo", QString::number((int) item->isSolo() ? 1 : 0)); _xml.writeAttribute("visible", QString::number((int) item->isVisible() ? 1 : 0)); - Shape *shape = item->getShape().get(); + MShape *shape = item->getShape().get(); _xml.writeStartElement("destination"); _xml.writeAttribute("shape", shape->getType()); writeShapeVertices(shape); diff --git a/ProjectWriter.h b/ProjectWriter.h index 1f5d99b..737e71b 100644 --- a/ProjectWriter.h +++ b/ProjectWriter.h @@ -32,7 +32,7 @@ class ProjectWriter private: void writeItem (Paint *item); void writeItem (Mapping *item); - void writeShapeVertices (Shape *shape); + void writeShapeVertices (MShape *shape); QXmlStreamWriter _xml; MappingManager *_manager; }; diff --git a/Shape.cpp b/Shape.cpp index fbfa349..17c67c0 100644 --- a/Shape.cpp +++ b/Shape.cpp @@ -19,7 +19,7 @@ #include "Shape.h" -void Shape::translate(int x, int y) +void MShape::translate(int x, int y) { for (QVector::iterator it = vertices.begin() ; it != vertices.end(); ++it) @@ -507,10 +507,10 @@ void Ellipse::setVertex(int i, const QPointF& v) transform *= fromUnitCircle(); // Set vertices. - Shape::setVertex(1, transform.map( getVertex(1) )); - Shape::setVertex(3, transform.map( getVertex(3) )); + MShape::setVertex(1, transform.map( getVertex(1) )); + MShape::setVertex(3, transform.map( getVertex(3) )); if (hasCenterControl()) - Shape::setVertex(4, transform.map( getVertex(4) )); + MShape::setVertex(4, transform.map( getVertex(4) )); } // If changed one of the two other points, just change the vertical axis. diff --git a/Shape.h b/Shape.h index 10b19d5..366a588 100644 --- a/Shape.h +++ b/Shape.h @@ -42,16 +42,16 @@ /** * Shape represented by a series of control points. */ -class Shape +class MShape { public: - typedef std::tr1::shared_ptr ptr; + typedef std::tr1::shared_ptr ptr; - Shape() {} - Shape(QVector vertices_) : + MShape() {} + MShape(QVector vertices_) : vertices(vertices_) {} - virtual ~Shape() {} + virtual ~MShape() {} virtual void build() {} @@ -105,10 +105,10 @@ protected: /** * This class represents a simple polygon (ie. the control points are vertices). */ -class Polygon : public Shape { +class Polygon : public MShape { public: Polygon() {} - Polygon(QVector vertices_) : Shape(vertices_) {} + Polygon(QVector vertices_) : MShape(vertices_) {} virtual ~Polygon() {} virtual QPolygonF toPolygon() const; @@ -246,7 +246,7 @@ protected: void _reorderVertices(); }; -class Ellipse : public Shape { +class Ellipse : public MShape { public: Ellipse() {} Ellipse(QPointF p1, QPointF p2, QPointF p3, QPointF p4, QPointF p5) @@ -284,13 +284,13 @@ public: QVector2D vFromCenter = QVector2D(getVertex(1)) - center; const QVector2D& projection = QVector2D::dotProduct( vFromCenter, vAxisNormalized ) * vAxisNormalized; - Shape::setVertex(1, (center + projection).toPointF()); - Shape::setVertex(3, (center - projection).toPointF()); + MShape::setVertex(1, (center + projection).toPointF()); + MShape::setVertex(3, (center - projection).toPointF()); if (hasCenterControl()) { // Clip control point. - Shape::setVertex(4, clipInside(getVertex(4))); + MShape::setVertex(4, clipInside(getVertex(4))); } } diff --git a/SourceGLCanvas.cpp b/SourceGLCanvas.cpp index 5a2d127..a567c0c 100644 --- a/SourceGLCanvas.cpp +++ b/SourceGLCanvas.cpp @@ -28,7 +28,7 @@ SourceGLCanvas::SourceGLCanvas(MainWindow* mainWindow, QWidget* parent) { } -Shape* SourceGLCanvas::getShapeFromMappingId(uid mappingId) +MShape* SourceGLCanvas::getShapeFromMappingId(uid mappingId) { if (mappingId == NULL_UID) return NULL; diff --git a/SourceGLCanvas.h b/SourceGLCanvas.h index 60161f1..88b08da 100644 --- a/SourceGLCanvas.h +++ b/SourceGLCanvas.h @@ -35,7 +35,7 @@ public: SourceGLCanvas(MainWindow* mainWindow, QWidget* parent = 0); // virtual ~SourceGLCanvas() {} - virtual Shape* getShapeFromMappingId(uid mappingId); + virtual MShape* getShapeFromMappingId(uid mappingId); private: virtual void doDraw(QPainter* painter); diff --git a/Util.cpp b/Util.cpp index c459b77..cbcfd95 100644 --- a/Util.cpp +++ b/Util.cpp @@ -165,7 +165,7 @@ void drawControlsVertex(QPainter* painter, const QPointF& vertex, bool selected, painter->drawLine( vertex + QPointF(offset, -offset), vertex + QPointF(-offset, offset) ); } -void drawControlsVertices(QPainter* painter, const QList* selectedVertices, const Shape& shape) +void drawControlsVertices(QPainter* painter, const QList* selectedVertices, const MShape& shape) { if (!selectedVertices) for (int i=0; i* selectedVertices, const Shape& shape); +void drawControlsVertices(QPainter* painter, const QList* selectedVertices, const MShape& shape); void drawControlsEllipse(QPainter* painter, const QList* selectedVertices, const Ellipse& ellipse); void drawControlsQuad(QPainter* painter, const QList* selectedVertices, const Quad& quad); void drawControlsMesh(QPainter* painter, const QList* selectedVertices, const Mesh& mesh);