Replaced STL vectors and maps by Qt-style

This commit is contained in:
Tats
2014-03-16 01:11:38 -04:00
parent f0ca7124db
commit 3910302f80
7 changed files with 40 additions and 34 deletions
+2 -2
View File
@@ -64,8 +64,8 @@ void DestinationGLCanvas::doDraw(QPainter* painter)
glPushMatrix();
MappingManager& mappingManager = MainWindow::getInstance().getMappingManager();
std::vector<Mapping::ptr> mappings = mappingManager.getVisibleMappings();
for (std::vector<Mapping::ptr>::const_iterator it = mappings.begin(); it != mappings.end(); ++it)
QVector<Mapping::ptr> mappings = mappingManager.getVisibleMappings();
for (QVector<Mapping::ptr>::const_iterator it = mappings.begin(); it != mappings.end(); ++it)
{
Mapping::ptr mapping = (*it);
+1 -1
View File
@@ -118,7 +118,7 @@ void MainWindow::handleMappingItemChanged(QListWidgetItem* item)
void MainWindow::handleMappingIndexesMoved()
{
std::vector<uid> newOrder;
QVector<uid> newOrder;
for (int row=mappingList->count()-1; row>=0; row--)
{
uid layerId = mappingList->item(row)->data(Qt::UserRole).toInt();
+2 -1
View File
@@ -24,6 +24,7 @@
#include <QtGui>
#include <QTimer>
#include <QVariant>
#include <QMap>
#include "SourceGLCanvas.h"
#ifdef HAVE_OSC
#include "OscInterface.h"
@@ -230,7 +231,7 @@ private:
QTimer *osc_timer;
// Maps from Mapping id to corresponding mapper.
std::map<uint, Mapper::ptr> mappers;
QMap<uint, Mapper::ptr> mappers;
private:
// Model.
+15 -13
View File
@@ -27,10 +27,10 @@ MappingManager::MappingManager()
}
std::map<uid, Mapping::ptr> MappingManager::getPaintMappings(const Paint::ptr paint) const
QMap<uid, Mapping::ptr> MappingManager::getPaintMappings(const Paint::ptr paint) const
{
std::map<uid, Mapping::ptr> paintMappings;
for (std::vector<Mapping::ptr>::const_iterator it = mappingVector.begin(); it != mappingVector.end(); ++it)
QMap<uid, Mapping::ptr> paintMappings;
for (QVector<Mapping::ptr>::const_iterator it = mappingVector.begin(); it != mappingVector.end(); ++it)
{
if ((*it)->getPaint() == paint)
paintMappings[(*it)->getId()] = *it;
@@ -38,9 +38,9 @@ std::map<uid, Mapping::ptr> MappingManager::getPaintMappings(const Paint::ptr pa
return paintMappings;
}
std::map<uid, Mapping::ptr> MappingManager::getPaintMappingsById(uid paintId) const
QMap<uid, Mapping::ptr> MappingManager::getPaintMappingsById(uid paintId) const
{
return getPaintMappings( paintMap.at(paintId) );
return getPaintMappings( paintMap[paintId] );
}
uid MappingManager::addPaint(Paint::ptr paint )
@@ -53,7 +53,7 @@ uid MappingManager::addPaint(Paint::ptr paint )
uid MappingManager::addMapping(Mapping::ptr mapping)
{
// Make sure the paint to which this mapping refers to exists in the manager.
Q_ASSERT (std::find(paintVector.begin(), paintVector.end(), mapping->getPaint()) != paintVector.end());
Q_ASSERT ( paintVector.contains(mapping->getPaint()) );
mappingVector.push_back(mapping);
mappingMap[mapping->getId()] = mapping;
@@ -61,13 +61,15 @@ uid MappingManager::addMapping(Mapping::ptr mapping)
return mapping->getId();
}
std::vector<Mapping::ptr> MappingManager::getVisibleMappings() const
{
std::vector<Mapping::ptr> visible;
QVector<Mapping::ptr> MappingManager::getVisibleMappings() const
{
QVector<Mapping::ptr> visible;
// First pass: check if one of the mappings is in solo mode.
bool hasSolo = false;
for (std::vector<Mapping::ptr>::const_iterator it = mappingVector.begin(); it != mappingVector.end(); ++it)
for (QVector<Mapping::ptr>::const_iterator it = mappingVector.begin(); it != mappingVector.end(); ++it)
{
if ((*it)->isSolo())
{
@@ -77,7 +79,7 @@ std::vector<Mapping::ptr> MappingManager::getVisibleMappings() const
}
// Second pass: fill the visible vector.
for (std::vector<Mapping::ptr>::const_iterator it = mappingVector.begin(); it != mappingVector.end(); ++it)
for (QVector<Mapping::ptr>::const_iterator it = mappingVector.begin(); it != mappingVector.end(); ++it)
{
// Solo has priority over invisible (mute)
if ( (hasSolo && (*it)->isSolo()) || (!hasSolo && (*it)->isVisible()) )
@@ -87,13 +89,13 @@ std::vector<Mapping::ptr> MappingManager::getVisibleMappings() const
return visible;
}
void MappingManager::reorderMappings(std::vector<uid> mappingIds)
void MappingManager::reorderMappings(QVector<uid> mappingIds)
{
Q_ASSERT( mappingIds.size() == mappingVector.size() );
mappingVector.clear();
for (std::vector<uid>::iterator it = mappingIds.begin(); it != mappingIds.end(); ++it)
for (QVector<uid>::iterator it = mappingIds.begin(); it != mappingIds.end(); ++it)
{
Q_ASSERT( mappingMap.find(*it) != mappingMap.end() );
Q_ASSERT( mappingMap.contains(*it) );
mappingVector.push_back( mappingMap[*it] );
}
}
+11 -8
View File
@@ -21,6 +21,9 @@
#ifndef MAPPINGMANAGER_H_
#define MAPPINGMANAGER_H_
#include <QVector>
#include <QMap>
#include "Paint.h"
#include "Mapping.h"
@@ -35,15 +38,15 @@ public:
private:
// Model.
std::vector<Paint::ptr> paintVector;
std::map<uid, Paint::ptr> paintMap;
std::vector<Mapping::ptr> mappingVector;
std::map<uid, Mapping::ptr> mappingMap;
QVector<Paint::ptr> paintVector;
QMap<uid, Paint::ptr> paintMap;
QVector<Mapping::ptr> mappingVector;
QMap<uid, Mapping::ptr> mappingMap;
public:
/// Returns the list of mappings associated with given paint.
std::map<uid, Mapping::ptr> getPaintMappings(const Paint::ptr paint) const;
std::map<uid, Mapping::ptr> getPaintMappingsById(uid paintId) const;
QMap<uid, Mapping::ptr> getPaintMappings(const Paint::ptr paint) const;
QMap<uid, Mapping::ptr> getPaintMappingsById(uid paintId) const;
uid addPaint(Paint::ptr paint);
// bool removePaint(Paint::ptr paint);
@@ -59,9 +62,9 @@ public:
Mapping::ptr getMapping(int i) { return mappingVector[i]; }
Mapping::ptr getMappingById(uid id) { return mappingMap[id]; }
void reorderMappings(std::vector<uid> mappingIds);
void reorderMappings(QVector<uid> mappingIds);
std::vector<Mapping::ptr> getVisibleMappings() const;
QVector<Mapping::ptr> getVisibleMappings() const;
void clearAll();
};
+7 -7
View File
@@ -73,7 +73,7 @@ void SourceGLCanvas::doDraw(QPainter* painter)
Q_CHECK_PTR(paint);
// Retrieve all mappings associated to paint.
std::map<uid, Mapping::ptr> mappings = MainWindow::getInstance().getMappingManager().getPaintMappingsById(paintId);
QMap<uid, Mapping::ptr> mappings = MainWindow::getInstance().getMappingManager().getPaintMappingsById(paintId);
if (paint->getType() == "color")
_drawColor(painter, paint, mappings);
@@ -81,7 +81,7 @@ void SourceGLCanvas::doDraw(QPainter* painter)
_drawTexture(painter, paint, mappings);
}
void SourceGLCanvas::_drawColor(QPainter* painter, Paint::ptr paint, std::map<uid, Mapping::ptr> mappings)
void SourceGLCanvas::_drawColor(QPainter* painter, Paint::ptr paint, QMap<uid, Mapping::ptr> mappings)
{
// Not doing anything for now.
Q_UNUSED(painter);
@@ -89,7 +89,7 @@ void SourceGLCanvas::_drawColor(QPainter* painter, Paint::ptr paint, std::map<ui
Q_UNUSED(mappings);
}
void SourceGLCanvas::_drawTexture(QPainter* painter, Paint::ptr paint, std::map<uid, Mapping::ptr> mappings)
void SourceGLCanvas::_drawTexture(QPainter* painter, Paint::ptr paint, QMap<uid, Mapping::ptr> mappings)
{
Q_UNUSED(painter);
@@ -153,19 +153,19 @@ void SourceGLCanvas::_drawTexture(QPainter* painter, Paint::ptr paint, std::map<
glDisable(GL_TEXTURE_2D);
for (std::map<uid, Mapping::ptr>::iterator it = mappings.begin(); it != mappings.end(); ++it)
for (QMap<uid, Mapping::ptr>::iterator it = mappings.begin(); it != mappings.end(); ++it)
{
// TODO: Ceci est un hack necessaire car tout est en fonction de la width/height de la texture.
// Il faut changer ca.
std::tr1::shared_ptr<TextureMapping> textureMapping = std::tr1::static_pointer_cast<TextureMapping>(it->second);
std::tr1::shared_ptr<TextureMapping> textureMapping = std::tr1::static_pointer_cast<TextureMapping>(it.value());
Q_CHECK_PTR(textureMapping);
std::tr1::shared_ptr<Shape> inputShape = std::tr1::static_pointer_cast<Quad>(textureMapping->getInputShape());
Q_CHECK_PTR(inputShape);
if (it->first == MainWindow::getInstance().getCurrentMappingId())
if (it.key() == MainWindow::getInstance().getCurrentMappingId())
{
Mapper::ptr mapper = MainWindow::getInstance().getMapperByMappingId(it->first);
Mapper::ptr mapper = MainWindow::getInstance().getMapperByMappingId(it.key());
Q_CHECK_PTR(mapper);
std::tr1::shared_ptr<TextureMapper> textureMapper = std::tr1::static_pointer_cast<TextureMapper>(mapper);
+2 -2
View File
@@ -41,8 +41,8 @@ public:
private:
virtual void doDraw(QPainter* painter);
void _drawColor(QPainter* painter, Paint::ptr paint, std::map<uid, Mapping::ptr> mappings);
void _drawTexture(QPainter* painter, Paint::ptr paint, std::map<uid, Mapping::ptr> mappings);
void _drawColor(QPainter* painter, Paint::ptr paint, QMap<uid, Mapping::ptr> mappings);
void _drawTexture(QPainter* painter, Paint::ptr paint, QMap<uid, Mapping::ptr> mappings);
};