/* * MappingManager.cpp * * (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "MappingManager.h" MappingManager::MappingManager() { // TODO Auto-generated constructor stub } std::vector MappingManager::getPaintMappings(const Paint::ptr paint) const { std::vector paintMappings; for (std::vector::const_iterator it = mappings.begin(); it != mappings.end(); ++it) { if ((*it)->getPaint() == paint) paintMappings.push_back(*it); } return paintMappings; } std::vector MappingManager::getPaintMappings(int i) const { return getPaintMappings( paints[i] ); } int MappingManager::addPaint(Paint::ptr paint) { paints.push_back(paint); return paints.size()-1; } int MappingManager::addImage(const QString imagePath, int frameWidth, int frameHeight) { Image* img = new Image(imagePath); img->setPosition( (frameWidth - img->getWidth() ) / 2.0f, (frameHeight - img->getHeight()) / 2.0f ); return addPaint(Paint::ptr(img)); } //bool MappingManager::removePaint(Paint::ptr paint) //{ // //} int MappingManager::addMapping(Mapping::ptr mapping) { if (std::find(paints.begin(), paints.end(), mapping->getPaint()) != paints.end()) { mappings.push_back(mapping); return mappings.size()-1; } else return (-1); } //bool MappingManager::removeMapping(Mapping::ptr mapping) //{ //}