diff --git a/DestinationGLCanvas.cpp b/DestinationGLCanvas.cpp index 71f3740..263f282 100644 --- a/DestinationGLCanvas.cpp +++ b/DestinationGLCanvas.cpp @@ -31,7 +31,7 @@ MShape* DestinationGLCanvas::getShapeFromMappingId(uid mappingId) const if (mappingId == NULL_UID) return NULL; else - return getMainWindow()->getMappingManager().getMappingById(mappingId)->getShape().get(); + return getMainWindow()->getMappingManager().getMappingById(mappingId)->getShape().data(); } ShapeGraphicsItem* DestinationGLCanvas::getShapeGraphicsItemFromMappingId(uid mappingId) const diff --git a/MainWindow.cpp b/MainWindow.cpp index 487e893..b3ec72f 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -233,7 +233,7 @@ void MainWindow::handlePaintChanged(Paint::ptr paint) { uid paintId = mappingManager->getPaintId(paint); if (paint->getType() == "media") { - std::tr1::shared_ptr media = std::tr1::static_pointer_cast(paint); + QSharedPointer media = qSharedPointerCast(paint); Q_CHECK_PTR(media); updatePaintItem(paintId, createFileIcon(media->getUri()), strippedName(media->getUri())); // QString fileName = QFileDialog::getOpenFileName(this, @@ -243,7 +243,7 @@ void MainWindow::handlePaintChanged(Paint::ptr paint) { // importMediaFile(fileName, paint, false); } if (paint->getType() == "image") { - std::tr1::shared_ptr image = std::tr1::static_pointer_cast(paint); + QSharedPointer image = qSharedPointerCast(paint); Q_CHECK_PTR(image); updatePaintItem(paintId, createImageIcon(image->getUri()), strippedName(image->getUri())); // QString fileName = QFileDialog::getOpenFileName(this, @@ -254,7 +254,7 @@ void MainWindow::handlePaintChanged(Paint::ptr paint) { } else if (paint->getType() == "color") { // Pop-up color-choosing dialog to choose color paint. - std::tr1::shared_ptr color = std::tr1::static_pointer_cast(paint); + QSharedPointer color = qSharedPointerCast(paint); Q_CHECK_PTR(color); updatePaintItem(paintId, createColorIcon(color->getColor()), strippedName(color->getColor().name())); } @@ -525,11 +525,11 @@ void MainWindow::addMesh() } else { - std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(paint); + QSharedPointer texture = qSharedPointerCast(paint); Q_CHECK_PTR(texture); - 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())); + MShape::ptr outputQuad = MShape::ptr(Util::createMeshForTexture(texture.data(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr inputQuad = MShape::ptr(Util::createMeshForTexture(texture.data(), sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new TextureMapping(paint, outputQuad, inputQuad); } @@ -561,11 +561,11 @@ void MainWindow::addTriangle() } else { - std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(paint); + QSharedPointer texture = qSharedPointerCast(paint); Q_CHECK_PTR(texture); - 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())); + MShape::ptr outputTriangle = MShape::ptr(Util::createTriangleForTexture(texture.data(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr inputTriangle = MShape::ptr(Util::createTriangleForTexture(texture.data(), sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new TextureMapping(paint, inputTriangle, outputTriangle); } @@ -597,11 +597,11 @@ void MainWindow::addEllipse() } else { - std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(paint); + QSharedPointer texture = qSharedPointerCast(paint); Q_CHECK_PTR(texture); - 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())); + MShape::ptr outputEllipse = MShape::ptr(Util::createEllipseForTexture(texture.data(), sourceCanvas->width(), sourceCanvas->height())); + MShape::ptr inputEllipse = MShape::ptr(Util::createEllipseForTexture(texture.data(), sourceCanvas->width(), sourceCanvas->height())); mappingPtr = new TextureMapping(paint, inputEllipse, outputEllipse); } @@ -1925,7 +1925,7 @@ bool MainWindow::importMediaFile(const QString &fileName, bool isImage) uint mediaId = createMediaPaint(NULL_UID, fileName, 0, 0, isImage, live); // Initialize position (center). - std::tr1::shared_ptr media = std::tr1::static_pointer_cast(mappingManager->getPaintById(mediaId)); + QSharedPointer media = qSharedPointerCast(mappingManager->getPaintById(mediaId)); Q_CHECK_PTR(media); if (_isPlaying) @@ -1961,7 +1961,7 @@ bool MainWindow::addColorPaint(const QColor& color) uint colorId = createColorPaint(NULL_UID, color); // Initialize position (center). - std::tr1::shared_ptr colorPaint = std::tr1::static_pointer_cast(mappingManager->getPaintById(colorId)); + QSharedPointer colorPaint = qSharedPointerCast(mappingManager->getPaintById(colorId)); Q_CHECK_PTR(colorPaint); // Does not do anything... @@ -2005,8 +2005,8 @@ void MainWindow::addPaintItem(uid paintId, const QIcon& icon, const QString& nam // connect(paintGui.get(), SIGNAL(valueChanged()), // this, SLOT(updateCanvases())); - connect(paintGui.get(), SIGNAL(valueChanged(Paint::ptr)), - this, SLOT(handlePaintChanged(Paint::ptr))); + connect(paintGui.data(), SIGNAL(valueChanged(Paint::ptr)), + this, SLOT(handlePaintChanged(Paint::ptr))); // Add paint item to paintList widget. QListWidgetItem* item = new QListWidgetItem(icon, name); @@ -2051,10 +2051,10 @@ void MainWindow::addMappingItem(uid mappingId) // Add mapper. // XXX hardcoded for textures - std::tr1::shared_ptr textureMapping; + QSharedPointer textureMapping; if (paintType == "media" || paintType == "image") { - textureMapping = std::tr1::static_pointer_cast(mapping); + textureMapping = qSharedPointerCast(mapping); Q_CHECK_PTR(textureMapping); } @@ -2107,17 +2107,17 @@ void MainWindow::addMappingItem(uid mappingId) mappingPropertyPanel->setEnabled(true); // When mapper value is changed, update canvases. - connect(mapper.get(), SIGNAL(valueChanged()), - this, SLOT(updateCanvases())); + connect(mapper.data(), SIGNAL(valueChanged()), + this, SLOT(updateCanvases())); - connect(sourceCanvas, SIGNAL(shapeChanged(MShape*)), - mapper.get(), SLOT(updateShape(MShape*))); + connect(sourceCanvas, SIGNAL(shapeChanged(MShape*)), + mapper.data(), SLOT(updateShape(MShape*))); connect(destinationCanvas, SIGNAL(shapeChanged(MShape*)), - mapper.get(), SLOT(updateShape(MShape*))); + mapper.data(), SLOT(updateShape(MShape*))); - connect(this, SIGNAL(paintChanged()), - mapper.get(), SLOT(updatePaint())); + connect(this, SIGNAL(paintChanged()), + mapper.data(), SLOT(updatePaint())); // Switch to mapping tab. contentTab->setCurrentWidget(mappingSplitter); @@ -2535,7 +2535,7 @@ bool MainWindow::setTextureUri(int texture_id, const std::string &uri) bool success = false; Paint::ptr paint = this->mappingManager->getPaintById(texture_id); - if (paint.get() == NULL) + if (paint.isNull()) { std::cout << "No such texture paint id " << texture_id << std::endl; success = false; @@ -2544,14 +2544,14 @@ bool MainWindow::setTextureUri(int texture_id, const std::string &uri) { if (paint->getType() == "media") { - Media *media = (Media *) paint.get(); // FIXME: use sharedptr cast + Media *media = static_cast(paint.data()); // FIXME: use sharedptr cast videoTimer->stop(); success = media->setUri(QString(uri.c_str())); videoTimer->start(); } else if (paint->getType() == "image") { - Image *media = (Image*) paint.get(); // FIXME: use sharedptr cast + Image *media = (Image*) paint.data(); // FIXME: use sharedptr cast videoTimer->stop(); success = media->setUri(QString(uri.c_str())); videoTimer->start(); @@ -2568,7 +2568,7 @@ bool MainWindow::setTextureUri(int texture_id, const std::string &uri) bool MainWindow::setTextureRate(int texture_id, double rate) { Paint::ptr paint = this->mappingManager->getPaintById(texture_id); - if (paint.get() == NULL) + if (paint.isNull()) { std::cout << "No such texture paint id " << texture_id << std::endl; return false; @@ -2577,7 +2577,7 @@ bool MainWindow::setTextureRate(int texture_id, double rate) { if (paint->getType() == "media") { - Media *media = (Media *) paint.get(); // FIXME: use sharedptr cast + Media *media = static_cast(paint.data()); // FIXME: use sharedptr cast videoTimer->stop(); media->setRate(rate); videoTimer->start(); diff --git a/Mapper.cpp b/Mapper.cpp index 529025c..9fc224b 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -45,7 +45,7 @@ void ShapeControlPainter::_paintVertices(QPainter *painter, const QList& se void PolygonControlPainter::_paintShape(QPainter *painter) { - Polygon* poly = static_cast(getShape().get()); + Polygon* poly = static_cast(getShape().data()); Q_ASSERT(poly); // Init colors and stroke. @@ -58,7 +58,7 @@ void PolygonControlPainter::_paintShape(QPainter *painter) void EllipseControlPainter::_paintShape(QPainter *painter) { - Ellipse* ellipse = static_cast(getShape().get()); + Ellipse* ellipse = static_cast(getShape().data()); Q_ASSERT(ellipse); // Init colors and stroke. @@ -76,7 +76,7 @@ void EllipseControlPainter::_paintShape(QPainter *painter) void MeshControlPainter::_paintShape(QPainter *painter) { - Mesh* mesh = static_cast(getShape().get()); + Mesh* mesh = static_cast(getShape().data()); Q_ASSERT(mesh); // Init colors and stroke. @@ -207,7 +207,7 @@ QPen ShapeGraphicsItem::_getRescaledShapeStroke(bool innerStroke) void ColorGraphicsItem::_prePaint(QPainter *painter, const QStyleOptionGraphicsItem *option) { - Color* color = static_cast(_mapping->getPaint().get()); + Color* color = static_cast(_mapping->getPaint().data()); Q_ASSERT(color); painter->setPen(Qt::NoPen); @@ -221,7 +221,7 @@ void ColorGraphicsItem::_prePaint(QPainter *painter, QPainterPath PolygonColorGraphicsItem::shape() const { QPainterPath path; - Polygon* poly = static_cast(_shape.get()); + Polygon* poly = static_cast(_shape.data()); Q_ASSERT(poly); path.addPolygon(poly->toPolygon()); return mapFromScene(path); @@ -231,7 +231,7 @@ void PolygonColorGraphicsItem::_doPaint(QPainter *painter, const QStyleOptionGraphicsItem *option) { Q_UNUSED(option); - Polygon* poly = static_cast(_shape.get()); + Polygon* poly = static_cast(_shape.data()); Q_ASSERT(poly); painter->drawPolygon(mapFromScene(poly->toPolygon())); } @@ -240,7 +240,7 @@ void PolygonColorGraphicsItem::_doPaintControls(QPainter* painter, const QStyleO { Q_UNUSED(option); painter->setPen(_getRescaledShapeStroke()); - Polygon* poly = static_cast(_shape.get()); + Polygon* poly = static_cast(_shape.data()); Q_ASSERT(poly); painter->drawPolygon(mapFromScene(poly->toPolygon())); } @@ -249,7 +249,7 @@ QPainterPath EllipseColorGraphicsItem::shape() const { // Create path for ellipse. QPainterPath path; - Ellipse* ellipse = static_cast(_shape.get()); + Ellipse* ellipse = static_cast(_shape.data()); Q_ASSERT(ellipse); QTransform transform; transform.translate(ellipse->getCenter().x(), ellipse->getCenter().y()); @@ -269,13 +269,13 @@ void EllipseColorGraphicsItem::_doPaint(QPainter* painter, TextureGraphicsItem::TextureGraphicsItem(Mapping::ptr mapping, bool output) : ShapeGraphicsItem(mapping, output) { - _textureMapping = std::tr1::static_pointer_cast(mapping); + _textureMapping = qSharedPointerCast(mapping); Q_CHECK_PTR(_textureMapping); - _texture = std::tr1::static_pointer_cast(_textureMapping->getPaint()); + _texture = qSharedPointerCast(_textureMapping->getPaint()); Q_CHECK_PTR(_texture); - _inputShape = std::tr1::static_pointer_cast(_textureMapping->getInputShape()); + _inputShape = qSharedPointerCast(_textureMapping->getInputShape()); Q_CHECK_PTR(_inputShape); } @@ -369,7 +369,7 @@ void TextureGraphicsItem::_postPaint(QPainter* painter, QPainterPath PolygonTextureGraphicsItem::shape() const { QPainterPath path; - Polygon* poly = static_cast(_shape.get()); + Polygon* poly = static_cast(_shape.data()); Q_ASSERT(poly); path.addPolygon(poly->toPolygon()); return mapFromScene(path); @@ -399,7 +399,7 @@ void PolygonTextureGraphicsItem::_doPaintControls(QPainter* painter, const QStyl { Q_UNUSED(option); painter->setPen(_getRescaledShapeStroke()); - Polygon* poly = static_cast(_shape.get()); + Polygon* poly = static_cast(_shape.data()); Q_ASSERT(poly); painter->drawPolygon(mapFromScene(poly->toPolygon())); } @@ -409,8 +409,8 @@ void MeshTextureGraphicsItem::_doDrawOutput(QPainter* painter) Q_UNUSED(painter); if (isOutput()) { - std::tr1::shared_ptr outputMesh = std::tr1::static_pointer_cast(_shape); - std::tr1::shared_ptr inputMesh = std::tr1::static_pointer_cast(_inputShape); + QSharedPointer outputMesh = qSharedPointerCast(_shape); + QSharedPointer inputMesh = qSharedPointerCast(_inputShape); QVector > outputQuads = outputMesh->getQuads2d(); QVector > inputQuads = inputMesh->getQuads2d(); for (int x = 0; x < outputMesh->nHorizontalQuads(); x++) @@ -430,7 +430,7 @@ void MeshTextureGraphicsItem::_doPaintControls(QPainter* painter, const QStyleOp { Q_UNUSED(option); - Mesh* mesh = static_cast(_shape.get()); + Mesh* mesh = static_cast(_shape.data()); Q_ASSERT(mesh); // Init colors and stroke. @@ -526,7 +526,7 @@ QPainterPath EllipseTextureGraphicsItem::shape() const { // Create path for ellipse. QPainterPath path; - Ellipse* ellipse = static_cast(_shape.get()); + Ellipse* ellipse = static_cast(_shape.data()); Q_ASSERT(ellipse); QTransform transform; transform.translate(ellipse->getCenter().x(), ellipse->getCenter().y()); @@ -544,8 +544,8 @@ void EllipseTextureGraphicsItem::_doDrawOutput(QPainter* painter) { Q_UNUSED(painter); // Get input and output ellipses. - std::tr1::shared_ptr inputEllipse = std::tr1::static_pointer_cast(_inputShape); - std::tr1::shared_ptr outputEllipse = std::tr1::static_pointer_cast(_shape); + QSharedPointer inputEllipse = qSharedPointerCast(_inputShape); + QSharedPointer outputEllipse = qSharedPointerCast(_shape); // Start / end angle. //const float startAngle = 0; @@ -645,7 +645,7 @@ Mapper::Mapper(Mapping::ptr mapping) _outputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), QObject::tr("Output shape")); - _buildShapeProperty(_outputItem, mapping->getShape().get()); + _buildShapeProperty(_outputItem, mapping->getShape().data()); _topItem->addSubProperty(_outputItem); // Collapse output shape. @@ -697,6 +697,11 @@ void Mapper::setValue(QtProperty* property, const QVariant& value) } } +void Mapper::updatePaint() +{ + _mapping->getPaint()->update(); +} + void Mapper::_buildShapeProperty(QtProperty* shapeItem, MShape* shape) { for (int i=0; inVertices(); i++) @@ -732,14 +737,7 @@ void Mapper::_updateShapeProperty(QtProperty* shapeItem, MShape* shape) ColorMapper::ColorMapper(Mapping::ptr mapping) : Mapper(mapping) { - color = std::tr1::static_pointer_cast(_mapping->getPaint()); - Q_CHECK_PTR(color); -} - -void ColorMapper::updatePaint() -{ - color.reset(); - color = std::tr1::static_pointer_cast(_mapping->getPaint()); + color = qSharedPointerCast(_mapping->getPaint()); Q_CHECK_PTR(color); } @@ -757,7 +755,7 @@ void ColorMapper::updatePaint() // painter->setPen(Qt::NoPen); // painter->setBrush(color->getColor()); // -// std::tr1::shared_ptr outputMesh = std::tr1::static_pointer_cast(outputShape); +// QSharedPointer outputMesh = qSharedPointerCast(outputShape); // QVector > outputQuads = outputMesh->getQuads2d(); // for (int x = 0; x < outputMesh->nHorizontalQuads(); x++) // { @@ -771,7 +769,7 @@ void ColorMapper::updatePaint() // //void MeshColorMapper::drawControls(QPainter* painter, const QList* selectedVertices) //{ -// std::tr1::shared_ptr outputMesh = std::tr1::static_pointer_cast(outputShape); +// QSharedPointer outputMesh = qSharedPointerCast(outputShape); // Util::drawControlsMesh(painter, selectedVertices, *outputMesh); //} // @@ -792,24 +790,24 @@ void ColorMapper::updatePaint() // ColorMapper::setValue(property, value); //} -TextureMapper::TextureMapper(std::tr1::shared_ptr mapping) +TextureMapper::TextureMapper(QSharedPointer mapping) : Mapper(mapping), _meshItem(NULL) { // Assign members pointers. - textureMapping = std::tr1::static_pointer_cast(_mapping); + textureMapping = qSharedPointerCast(_mapping); Q_CHECK_PTR(textureMapping); - texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); + texture = qSharedPointerCast(_mapping->getPaint()); Q_CHECK_PTR(texture); - inputShape = std::tr1::static_pointer_cast(textureMapping->getInputShape()); + inputShape = textureMapping.toStrongRef()->getInputShape(); Q_CHECK_PTR(inputShape); // Input shape. _inputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), QObject::tr("Input shape")); - _buildShapeProperty(_inputItem, textureMapping->getInputShape().get()); + _buildShapeProperty(_inputItem, inputShape.data()); _topItem->insertSubProperty(_inputItem, _opacityItem); // insert // Collapse input shape. @@ -844,14 +842,14 @@ TextureMapper::TextureMapper(std::tr1::shared_ptr mapping) void TextureMapper::updateShape(MShape* shape) { - std::tr1::shared_ptr textureMapping = std::tr1::static_pointer_cast(_mapping); + QSharedPointer textureMapping = qSharedPointerCast(_mapping); Q_CHECK_PTR(textureMapping); - std::tr1::shared_ptr texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); + QSharedPointer texture = qSharedPointerCast(textureMapping->getPaint()); Q_CHECK_PTR(texture); - MShape* inputShape = textureMapping->getInputShape().get(); - MShape* outputShape = textureMapping->getShape().get(); + MShape* inputShape = textureMapping->getInputShape().data(); + MShape* outputShape = textureMapping->getShape().data(); if (shape == inputShape) { _updateShapeProperty(_inputItem, inputShape); @@ -863,12 +861,6 @@ void TextureMapper::updateShape(MShape* shape) } -void TextureMapper::updatePaint() -{ - texture.reset(); - texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); - Q_CHECK_PTR(texture); -} // //void TextureMapper::_preDraw(QPainter* painter) //{ @@ -910,17 +902,17 @@ void TextureMapper::updatePaint() // //void PolygonTextureMapper::drawControls(QPainter* painter, const QList* selectedVertices) //{ -// std::tr1::shared_ptr outputPoly = std::tr1::static_pointer_cast(outputShape); +// QSharedPointer outputPoly = qSharedPointerCast(outputShape); // Util::drawControlsPolygon(painter, selectedVertices, *outputPoly); //} // //void PolygonTextureMapper::drawInputControls(QPainter* painter, const QList* selectedVertices) //{ -// std::tr1::shared_ptr inputPoly = std::tr1::static_pointer_cast(inputShape); +// QSharedPointer inputPoly = qSharedPointerCast(inputShape); // Util::drawControlsPolygon(painter, selectedVertices, *inputPoly); //} -TriangleTextureMapper::TriangleTextureMapper(std::tr1::shared_ptr mapping) +TriangleTextureMapper::TriangleTextureMapper(QSharedPointer mapping) : PolygonTextureMapper(mapping) { _graphicsItem = new TriangleTextureGraphicsItem(_mapping, true); @@ -941,14 +933,14 @@ TriangleTextureMapper::TriangleTextureMapper(std::tr1::shared_ptr mapping) +MeshTextureMapper::MeshTextureMapper(QSharedPointer mapping) : PolygonTextureMapper(mapping) { _graphicsItem = new MeshTextureGraphicsItem(_mapping, true); _inputGraphicsItem = new MeshTextureGraphicsItem(_mapping, false); // Add mesh sub property. - Mesh* mesh = (Mesh*)textureMapping->getShape().get(); + QSharedPointer mesh = qSharedPointerCast(_mapping->getShape()); _meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Dimensions")); _meshItem->setValue(QSize(mesh->nColumns(), mesh->nRows())); _meshItem->setAttribute("minimum", QSize(2,2)); @@ -959,11 +951,8 @@ void MeshTextureMapper::setValue(QtProperty* property, const QVariant& value) { if (property == _meshItem) { - std::tr1::shared_ptr textureMapping = std::tr1::static_pointer_cast(_mapping); - Q_CHECK_PTR(textureMapping); - - Mesh* outputMesh = static_cast(textureMapping->getShape().get()); - Mesh* inputMesh = static_cast(textureMapping->getInputShape().get()); + QSharedPointer outputMesh = qSharedPointerCast(_mapping->getShape()); + QSharedPointer inputMesh = qSharedPointerCast(textureMapping.toStrongRef()->getShape()); QSize size = (static_cast(property))->value().toSize(); if (outputMesh->nColumns() != size.width() || outputMesh->nRows() != size.height() || inputMesh->nColumns() != size.width() || inputMesh->nRows() != size.height()) @@ -983,7 +972,7 @@ void MeshTextureMapper::setValue(QtProperty* property, const QVariant& value) TextureMapper::setValue(property, value); } -EllipseTextureMapper::EllipseTextureMapper(std::tr1::shared_ptr mapping) +EllipseTextureMapper::EllipseTextureMapper(QSharedPointer mapping) : PolygonTextureMapper(mapping) { _graphicsItem = new EllipseTextureGraphicsItem(_mapping, true); diff --git a/Mapper.h b/Mapper.h index 374510c..042f4e7 100644 --- a/Mapper.h +++ b/Mapper.h @@ -30,8 +30,6 @@ #include #endif -#include - #include #include @@ -58,7 +56,7 @@ class ShapeGraphicsItem; class ShapeControlPainter { public: - typedef std::tr1::shared_ptr ptr; + typedef QSharedPointer ptr; ShapeControlPainter(ShapeGraphicsItem* shapeItem); virtual ~ShapeControlPainter() {} @@ -224,9 +222,9 @@ protected: virtual void _doDrawInput(QPainter* painter); protected: - std::tr1::shared_ptr _textureMapping; - std::tr1::shared_ptr _texture; - std::tr1::shared_ptr _inputShape; + QSharedPointer _textureMapping; + QSharedPointer _texture; + QSharedPointer _inputShape; }; /// Graphics item for textured polygons (eg. triangles). @@ -306,11 +304,13 @@ class Mapper : public QObject Q_OBJECT public: - typedef std::tr1::shared_ptr ptr; + typedef QSharedPointer ptr; protected: /// Constructor. A mapper applies to a mapping. Mapper(Mapping::ptr mapping); + +public: virtual ~Mapper(); public: @@ -327,7 +327,7 @@ public: public slots: virtual void setValue(QtProperty* property, const QVariant& value); virtual void updateShape(MShape* shape) { Q_UNUSED(shape); } - virtual void updatePaint() {} + virtual void updatePaint(); signals: void valueChanged(); @@ -362,15 +362,12 @@ class ColorMapper : public Mapper { Q_OBJECT -public slots: - virtual void updatePaint(); - protected: ColorMapper(Mapping::ptr mapping); virtual ~ColorMapper() {} protected: - std::tr1::shared_ptr color; + QSharedPointer color; }; class PolygonColorMapper : public ColorMapper @@ -422,7 +419,7 @@ class TextureMapper : public Mapper Q_OBJECT public: - TextureMapper(std::tr1::shared_ptr mapping); + TextureMapper(QSharedPointer mapping); virtual ~TextureMapper() {} // /** @@ -437,7 +434,6 @@ public: public slots: virtual void updateShape(MShape* shape); - virtual void updatePaint(); //protected: // virtual void _doDraw(QPainter* painter) = 0; @@ -449,9 +445,9 @@ protected: QtVariantProperty* _meshItem; // FIXME: use typedefs, member of the class for type names that are too long to type: - std::tr1::shared_ptr textureMapping; - std::tr1::shared_ptr texture; - std::tr1::shared_ptr inputShape; + QWeakPointer textureMapping; + QWeakPointer texture; + QWeakPointer inputShape; }; class PolygonTextureMapper : public TextureMapper @@ -459,7 +455,7 @@ class PolygonTextureMapper : public TextureMapper Q_OBJECT public: - PolygonTextureMapper(std::tr1::shared_ptr mapping) : TextureMapper(mapping) {} + PolygonTextureMapper(QSharedPointer mapping) : TextureMapper(mapping) {} virtual ~PolygonTextureMapper() {} }; @@ -468,7 +464,7 @@ class TriangleTextureMapper : public PolygonTextureMapper Q_OBJECT public: - TriangleTextureMapper(std::tr1::shared_ptr mapping); + TriangleTextureMapper(QSharedPointer mapping); virtual ~TriangleTextureMapper() {} }; @@ -477,7 +473,7 @@ class MeshTextureMapper : public PolygonTextureMapper Q_OBJECT public: - MeshTextureMapper(std::tr1::shared_ptr mapping); + MeshTextureMapper(QSharedPointer mapping); virtual ~MeshTextureMapper() {} public slots: @@ -491,7 +487,7 @@ class EllipseTextureMapper : public PolygonTextureMapper { Q_OBJECT public: - EllipseTextureMapper(std::tr1::shared_ptr mapping); + EllipseTextureMapper(QSharedPointer mapping); virtual ~EllipseTextureMapper() {} protected: diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index a6bf567..37eb0fb 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -497,7 +497,7 @@ void MapperGLCanvas::_glueVertex(QPointF* p) MappingManager manager = MainWindow::instance()->getMappingManager(); for (int i = 0; i < manager.nMappings(); i++) { - MShape *shape = manager.getMapping(i)->getShape().get(); + MShape *shape = manager.getMapping(i)->getShape().data(); if (shape && shape != getCurrentShape()) { for (int vertex = 0; vertex < shape->nVertices(); vertex++) diff --git a/Mapping.h b/Mapping.h index ee0a3b0..7a6d568 100644 --- a/Mapping.h +++ b/Mapping.h @@ -22,7 +22,7 @@ #define MAPPING_H_ #include -#include + #include "Shape.h" #include "Paint.h" #include "UidAllocator.h" @@ -64,7 +64,7 @@ protected: Mapping(Paint::ptr paint, MShape::ptr shape, uid id=NULL_UID); public: - typedef std::tr1::shared_ptr ptr; + typedef QSharedPointer ptr; virtual ~Mapping(); @@ -118,7 +118,6 @@ public: float getOpacity() const { return _opacity * _paint->getOpacity(); } void setPaint(Paint::ptr p) { _paint = p; } - void removePaint() { if (_paint) delete _paint.get(); } }; /** diff --git a/MediaImpl.h b/MediaImpl.h index d7c8a6b..1e77083 100644 --- a/MediaImpl.h +++ b/MediaImpl.h @@ -37,7 +37,6 @@ #else #include #endif -#include /** * Private declaration of the video player. diff --git a/OscInterface.h b/OscInterface.h index 6aa0a7a..f708cd9 100644 --- a/OscInterface.h +++ b/OscInterface.h @@ -24,10 +24,10 @@ #define OSC_INTERFACE_H_ #ifdef HAVE_OSC -#include +#include + #include "concurrentqueue.h" #include "OscReceiver.h" -#include class MainWindow; // forward decl @@ -37,7 +37,7 @@ class MainWindow; // forward decl class OscInterface { public: - typedef std::tr1::shared_ptr ptr; + typedef QSharedPointer ptr; OscInterface( //MainWindow* owner, const std::string &listen_port); diff --git a/Paint.h b/Paint.h index c415e52..de5b8c3 100644 --- a/Paint.h +++ b/Paint.h @@ -34,8 +34,6 @@ #include #endif -#include - #include "UidAllocator.h" /** @@ -56,7 +54,7 @@ protected: Paint(uid id=NULL_UID); public: - typedef std::tr1::shared_ptr ptr; + typedef QSharedPointer ptr; virtual ~Paint(); diff --git a/PaintGui.cpp b/PaintGui.cpp index c884ca9..88fb6fe 100644 --- a/PaintGui.cpp +++ b/PaintGui.cpp @@ -73,7 +73,7 @@ void PaintGui::setValue(QtProperty* property, const QVariant& value) ColorGui::ColorGui(Paint::ptr paint) : PaintGui(paint) { - color = std::tr1::static_pointer_cast(paint); + color = qSharedPointerCast(paint); Q_CHECK_PTR(color); _colorItem = _variantManager->addProperty(QVariant::Color, @@ -99,7 +99,7 @@ TextureGui::TextureGui(Paint::ptr paint) : PaintGui(paint) { ImageGui::ImageGui(Paint::ptr paint) : TextureGui(paint) { - image = std::tr1::static_pointer_cast(paint); + image = qSharedPointerCast(paint); Q_CHECK_PTR(image); _imageFileItem = _variantManager->addProperty(VariantManager::filePathTypeId(), @@ -123,7 +123,7 @@ void ImageGui::setValue(QtProperty* property, const QVariant& value) { MediaGui::MediaGui(Paint::ptr paint) : TextureGui(paint) { - media = std::tr1::static_pointer_cast(paint); + media = qSharedPointerCast(paint); Q_CHECK_PTR(media); _mediaFileItem = _variantManager->addProperty(VariantManager::filePathTypeId(), diff --git a/PaintGui.h b/PaintGui.h index f2b648d..7cc4aaf 100644 --- a/PaintGui.h +++ b/PaintGui.h @@ -29,8 +29,6 @@ #include #endif -#include - #include "MM.h" #include "Paint.h" @@ -48,7 +46,7 @@ class PaintGui : public QObject { Q_OBJECT public: - typedef std::tr1::shared_ptr ptr; + typedef QSharedPointer ptr; public: // TODO: should be protected @@ -86,7 +84,7 @@ public slots: virtual void setValue(QtProperty* property, const QVariant& value); protected: - std::tr1::shared_ptr color; + QSharedPointer color; QtVariantProperty* _colorItem; }; @@ -112,7 +110,7 @@ public slots: virtual void setValue(QtProperty* property, const QVariant& value); protected: - std::tr1::shared_ptr image; + QSharedPointer image; QtVariantProperty* _imageFileItem; }; @@ -127,7 +125,7 @@ public slots: virtual void setValue(QtProperty* property, const QVariant& value); protected: - std::tr1::shared_ptr media; + QSharedPointer media; QtVariantProperty* _mediaFileItem; QtVariantProperty* _mediaRateItem; QtVariantProperty* _mediaVolumeItem; diff --git a/ProjectWriter.cpp b/ProjectWriter.cpp index b3a06ab..851e372 100644 --- a/ProjectWriter.cpp +++ b/ProjectWriter.cpp @@ -37,12 +37,12 @@ bool ProjectWriter::writeFile(QIODevice *device) _xml.writeStartElement("paints"); for (int i = 0; i < _manager->nPaints(); i++) - writeItem(_manager->getPaint(i).get()); + writeItem(_manager->getPaint(i).data()); _xml.writeEndElement(); _xml.writeStartElement("mappings"); for (int i = 0; i < _manager->nMappings(); i++) - writeItem(_manager->getMapping(i).get()); + writeItem(_manager->getMapping(i).data()); _xml.writeEndElement(); _xml.writeEndElement(); @@ -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)); - MShape *shape = item->getShape().get(); + MShape *shape = item->getShape().data(); _xml.writeStartElement("destination"); _xml.writeAttribute("shape", shape->getType()); writeShapeVertices(shape); @@ -159,7 +159,7 @@ void ProjectWriter::writeItem(Mapping *item) if (item->getType().endsWith("_texture")) { TextureMapping *tex = (TextureMapping *) item; - shape = tex->getInputShape().get(); + shape = tex->getInputShape().data(); _xml.writeStartElement("source"); _xml.writeAttribute("shape", shape->getType()); diff --git a/Shape.h b/Shape.h index f1fe591..c064d62 100644 --- a/Shape.h +++ b/Shape.h @@ -20,7 +20,6 @@ #ifndef SHAPE_H_ #define SHAPE_H_ -#include #include #include @@ -45,7 +44,7 @@ class MShape { public: - typedef std::tr1::shared_ptr ptr; + typedef QSharedPointer ptr; MShape() {} MShape(QVector vertices_) : diff --git a/SourceGLCanvas.cpp b/SourceGLCanvas.cpp index 7236b7f..01239f5 100644 --- a/SourceGLCanvas.cpp +++ b/SourceGLCanvas.cpp @@ -37,7 +37,7 @@ MShape* SourceGLCanvas::getShapeFromMappingId(uid mappingId) const { Mapping::ptr mapping = getMainWindow()->getMappingManager().getMappingById(mappingId); Q_CHECK_PTR(mapping); - return mapping->getInputShape().get(); + return mapping->getInputShape().data(); } }