From 6595d9911a03208bc8034859fb2306c8238174b1 Mon Sep 17 00:00:00 2001 From: Tats Date: Tue, 10 Dec 2013 22:37:45 -0500 Subject: [PATCH] Replaced Quads by Meshes --- Defs.h | 28 ++++++++++++++++++++++++++++ MainWindow.cpp | 9 +++++---- MainWindow.h | 2 +- Util.cpp | 2 +- Util.h | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 Defs.h diff --git a/Defs.h b/Defs.h new file mode 100644 index 0000000..7b70781 --- /dev/null +++ b/Defs.h @@ -0,0 +1,28 @@ +/* + * Defs.h + * + * (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 . + */ + +#ifndef DEFS_H_ +#define DEFS_H_ + +#define DEFAULT_WINDOW_WIDTH 640 +#define DEFAULT_WINDOW_HEIGHT 480 + +#endif + + diff --git a/MainWindow.cpp b/MainWindow.cpp index 65595f5..4adb719 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -191,7 +191,7 @@ void MainWindow::import() } } -void MainWindow::addQuad() +void MainWindow::addMesh() { // Create default quad. @@ -203,8 +203,9 @@ void MainWindow::addQuad() Q_CHECK_PTR(texture); // Create input and output quads. - Shape::ptr outputQuad = Shape::ptr(Util::createQuadForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); - Shape::ptr inputQuad = Shape::ptr(Util::createQuadForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height())); + qDebug() << "adding mesh" << endl; + 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())); // Create texture mapping. Mapping::ptr mapping(new TextureMapping(paint, outputQuad, inputQuad)); @@ -423,7 +424,7 @@ void MainWindow::createActions() addQuadAction = new QAction(tr("&Add quad"), this); addQuadAction->setIcon(QIcon(":/images/draw-rectangle-2.png")); addQuadAction->setStatusTip(tr("Add quad")); - connect(addQuadAction, SIGNAL(triggered()), this, SLOT(addQuad())); + connect(addQuadAction, SIGNAL(triggered()), this, SLOT(addMesh())); addTriangleAction = new QAction(tr("&Add triangle"), this); addTriangleAction->setIcon(QIcon(":/images/draw-triangle.png")); diff --git a/MainWindow.h b/MainWindow.h index 184f680..6fcdf51 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -62,7 +62,7 @@ private slots: void handleLayerItemSelectionChanged(); void handleLayerItemChanged(QListWidgetItem* item); void handleLayerIndexesMoved(); - void addQuad(); + void addMesh(); void addTriangle(); void windowModified(); diff --git a/Util.cpp b/Util.cpp index 37429da..c7d8b8f 100644 --- a/Util.cpp +++ b/Util.cpp @@ -56,7 +56,7 @@ int map_int(int value, int istart, int istop, int ostart, int ostop) return std::max(std::min(int(ret), ostop), ostart); } -Mesh* createQuadForTexture(Texture* texture, int frameWidth, int frameHeight) +Mesh* createMeshForTexture(Texture* texture, int frameWidth, int frameHeight) { return new Mesh( Point(texture->getX(), texture->getY()), diff --git a/Util.h b/Util.h index 842c809..a20debb 100644 --- a/Util.h +++ b/Util.h @@ -39,7 +39,7 @@ float map_float(float value, float istart, float istop, float ostart, float osto int map_int(int value, int istart, int istop, int ostart, int ostop); -Mesh* createQuadForTexture(Texture* texture, int frameWidth, int frameHeight); +Mesh* createMeshForTexture(Texture* texture, int frameWidth, int frameHeight); Triangle* createTriangleForTexture(Texture* texture, int frameWidth, int frameHeight); } // end of namespace