mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Resolved all compilation errors from merging
This commit is contained in:
+82
-1
@@ -22,6 +22,8 @@
|
||||
#include "ProjectWriter.h"
|
||||
#include "ProjectReader.h"
|
||||
|
||||
MainWindow* MainWindow::instance = 0;
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
if (!instance)
|
||||
@@ -621,7 +623,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
||||
setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("LibreMapping Project")));
|
||||
}
|
||||
|
||||
bool MainWindow::importFile(const QString &fileName)
|
||||
bool MainWindow::importMediaFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
@@ -736,3 +738,82 @@ QString MainWindow::strippedName(const QString &fullFileName)
|
||||
{
|
||||
return QFileInfo(fullFileName).fileName();
|
||||
}
|
||||
|
||||
void MainWindow::startOscReceiver()
|
||||
{
|
||||
#ifdef HAVE_OSC
|
||||
int port = config_osc_receive_port;
|
||||
std::ostringstream os;
|
||||
os << port;
|
||||
osc_interface.reset(new OscInterface(this, os.str()));
|
||||
if (port != 0)
|
||||
{
|
||||
osc_interface->start();
|
||||
}
|
||||
osc_timer = new QTimer(this); // FIXME: memleak?
|
||||
connect(osc_timer, SIGNAL(timeout()), this, SLOT(pollOscInterface()));
|
||||
osc_timer->start();
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::pollOscInterface()
|
||||
{
|
||||
#ifdef HAVE_OSC
|
||||
osc_interface->consume_commands();
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::applyOscCommand(QVariantList & command)
|
||||
{
|
||||
bool VERBOSE = true;
|
||||
|
||||
if (VERBOSE)
|
||||
{
|
||||
std::cout << "MainWindow::applyOscCommand: Receive OSC: ";
|
||||
for (int i = 0; i < command.size(); ++i)
|
||||
{
|
||||
if (command.at(i).type() == QVariant::Int)
|
||||
{
|
||||
std::cout << command.at(i).toInt() << " ";
|
||||
}
|
||||
else if (command.at(i).type() == QVariant::Double)
|
||||
{
|
||||
std::cout << command.at(i).toDouble() << " ";
|
||||
}
|
||||
else if (command.at(i).type() == QVariant::String)
|
||||
{
|
||||
std::cout << command.at(i).toString().toStdString() << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "(?) ";
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout.flush();
|
||||
}
|
||||
|
||||
if (command.size() < 2)
|
||||
return;
|
||||
if (command.at(0).type() != QVariant::String)
|
||||
return;
|
||||
if (command.at(1).type() != QVariant::String)
|
||||
return;
|
||||
std::string path = command.at(0).toString().toStdString();
|
||||
std::string typetags = command.at(1).toString().toStdString();
|
||||
|
||||
// Handle all OSC messages here
|
||||
if (path == "/image/uri" && typetags == "s")
|
||||
{
|
||||
std::string image_uri = command.at(2).toString().toStdString();
|
||||
std::cout << "TODO load /image/uri " << image_uri << std::endl;
|
||||
}
|
||||
else if (path == "/add/quad")
|
||||
addMesh();
|
||||
else if (path == "/add/triangle")
|
||||
addTriangle();
|
||||
else if (path == "/project/save")
|
||||
save();
|
||||
else if (path == "/project/open")
|
||||
open();
|
||||
}
|
||||
|
||||
+2
-1
@@ -48,6 +48,7 @@ public:
|
||||
~MainWindow();
|
||||
static MainWindow& getInstance();
|
||||
static void setInstance(MainWindow* inst);
|
||||
void applyOscCommand(QVariantList & command);
|
||||
|
||||
protected:
|
||||
// Events.
|
||||
@@ -88,7 +89,7 @@ private:
|
||||
bool loadFile(const QString &fileName);
|
||||
bool saveFile(const QString &fileName);
|
||||
void setCurrentFile(const QString &fileName);
|
||||
bool importFile(const QString &fileName);
|
||||
bool importMediaFile(const QString &fileName);
|
||||
void addLayerItem(uint layerId);
|
||||
void clearWindow();
|
||||
QString strippedName(const QString &fullFileName);
|
||||
|
||||
+12
-12
@@ -78,9 +78,9 @@ void TextureMapper::setValue(QtProperty* property, const QVariant& value)
|
||||
QPointF p = value.toPointF();
|
||||
Shape* shape = it->second.first;
|
||||
int v = it->second.second;
|
||||
if (shape->getVertex(v).toQPointF() != p)
|
||||
if (*shape->getVertex(v) != p)
|
||||
{
|
||||
shape->setVertex(v, Point(p));
|
||||
shape->setVertex(v, p);
|
||||
emit valueChanged();
|
||||
}
|
||||
}
|
||||
@@ -165,8 +165,8 @@ void TextureMapper::drawShapeContour(const Shape& shape, int lineWidth, const QC
|
||||
for (int i = 0; i < shape.nVertices()+1; i++)
|
||||
{
|
||||
glVertex2f(
|
||||
shape.getVertex(i % shape.nVertices()).x,
|
||||
shape.getVertex(i % shape.nVertices()).y
|
||||
shape.getVertex(i % shape.nVertices())->x(),
|
||||
shape.getVertex(i % shape.nVertices())->y()
|
||||
);
|
||||
}
|
||||
glEnd();
|
||||
@@ -181,8 +181,8 @@ void TextureMapper::_buildShapeProperty(QtProperty* shapeItem, Shape* shape)
|
||||
QtVariantProperty* pointItem = _variantManager->addProperty(QVariant::PointF,
|
||||
QObject::tr("Point %1").arg(i));
|
||||
|
||||
Point p = shape->getVertex(i);
|
||||
pointItem->setValue(QPointF(p.x, p.y));
|
||||
Point *p = shape->getVertex(i);
|
||||
pointItem->setValue(*p);
|
||||
|
||||
shapeItem->addSubProperty(pointItem);
|
||||
_propertyToVertex[pointItem] = std::make_pair(shape, i);
|
||||
@@ -199,8 +199,8 @@ void TextureMapper::_updateShapeProperty(QtProperty* shapeItem, Shape* shape)
|
||||
if (i < pointItems.size())
|
||||
{
|
||||
QtVariantProperty* pointItem = (QtVariantProperty*)pointItems[i];
|
||||
Point p = shape->getVertex(i);
|
||||
pointItem->setValue(QPointF(p.x, p.y));
|
||||
Point *p = shape->getVertex(i);
|
||||
pointItem->setValue(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,11 +297,11 @@ void MeshTextureMapper::_doDraw()
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Util::correctGlTexCoord(
|
||||
(inputQuad.getVertex(i).x - texture->getX()) / (GLfloat) texture->getWidth(),
|
||||
(inputQuad.getVertex(i).y - texture->getY()) / (GLfloat) texture->getHeight());
|
||||
(inputQuad.getVertex(i)->x() - texture->getX()) / (GLfloat) texture->getWidth(),
|
||||
(inputQuad.getVertex(i)->y() - texture->getY()) / (GLfloat) texture->getHeight());
|
||||
glVertex2f(
|
||||
outputQuad.getVertex(i).x,
|
||||
outputQuad.getVertex(i).y
|
||||
outputQuad.getVertex(i)->x(),
|
||||
outputQuad.getVertex(i)->y()
|
||||
);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
+10
-10
@@ -156,8 +156,8 @@ void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event)
|
||||
p->setX(event->x());
|
||||
p->setY(event->y());
|
||||
|
||||
glueVertex(shape, &p);
|
||||
shape->setVertex(_active_vertex, p);
|
||||
glueVertex(shape, p);
|
||||
shape->setVertex(_active_vertex, *p);
|
||||
|
||||
update();
|
||||
emit shapeChanged(getCurrentShape());
|
||||
@@ -172,15 +172,15 @@ void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (_shapefirstgrab == false)
|
||||
{
|
||||
shape->translate(event->x() - p.x, event->y() - p.y);
|
||||
shape->translate(event->x() - p.x(), event->y() - p.y());
|
||||
update();
|
||||
emit shapeChanged(getCurrentShape());
|
||||
}
|
||||
else
|
||||
_shapefirstgrab = false;
|
||||
}
|
||||
p.x = event->x();
|
||||
p.y = event->y();
|
||||
p.setX( event->x() );
|
||||
p.setY( event->y() );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -275,12 +275,12 @@ void MapperGLCanvas::glueVertex(Shape *orig, Point *p)
|
||||
{
|
||||
for (int vertex = 0; vertex < shape->nVertices(); vertex++)
|
||||
{
|
||||
Point v = shape->getVertex(vertex);
|
||||
if ((abs(v.x - p->x) < dist_stick) &&
|
||||
(abs(v.y - p->y) < dist_stick))
|
||||
Point *v = shape->getVertex(vertex);
|
||||
if ((abs(v->x() - p->x()) < dist_stick) &&
|
||||
(abs(v->y() - p->y()) < dist_stick))
|
||||
{
|
||||
p->x = v.x;
|
||||
p->y = v.y;
|
||||
p->setX(v->x());
|
||||
p->setY(v->y());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -52,7 +52,8 @@ uint MappingManager::addPaint(Paint::ptr paint)
|
||||
|
||||
uint MappingManager::addImage(const QString imagePath, int frameWidth, int frameHeight)
|
||||
{
|
||||
Image* img = new Image(imagePath);
|
||||
std::string name = _nameAllocator.allocateName("image_");
|
||||
Image* img = new Image(name.c_str(), imagePath);
|
||||
|
||||
img->setPosition( (frameWidth - img->getWidth() ) / 2.0f,
|
||||
(frameHeight - img->getHeight()) / 2.0f );
|
||||
|
||||
@@ -45,6 +45,8 @@ private:
|
||||
std::vector<Layer::ptr> layerVector;
|
||||
std::map<uint, Layer::ptr> layerMap;
|
||||
|
||||
NameAllocator _nameAllocator;
|
||||
|
||||
public:
|
||||
/// Returns the list of mappings associated with given paint.
|
||||
std::map<uint, Mapping::ptr> getPaintMappings(const Paint::ptr paint) const;
|
||||
|
||||
@@ -23,34 +23,34 @@ bool Shape::includesPoint(int x, int y)
|
||||
{
|
||||
Point *prev = NULL, *cur;
|
||||
int left = 0, right = 0, maxy, miny;
|
||||
for (std::vector<Point>::iterator it = vertices.begin() ; it !=
|
||||
vertices.end(); it++)
|
||||
for (std::vector<Point*>::iterator it = vertices.begin() ;
|
||||
it != vertices.end(); it++)
|
||||
{
|
||||
if (!prev) {
|
||||
prev = &vertices.back();
|
||||
prev = vertices.back();
|
||||
}
|
||||
cur = &(*it);
|
||||
miny = std::min(cur->y, prev->y);
|
||||
maxy = std::max(cur->y, prev->y);
|
||||
cur = *it;
|
||||
miny = std::min(cur->y(), prev->y());
|
||||
maxy = std::max(cur->y(), prev->y());
|
||||
|
||||
if (y > miny && y < maxy) {
|
||||
if (prev->x == cur->x)
|
||||
if (prev->x() == cur->x())
|
||||
{
|
||||
if (x < cur->x)
|
||||
if (x < cur->x())
|
||||
right++;
|
||||
else left++;
|
||||
}
|
||||
else
|
||||
{
|
||||
double slope = (cur->y - prev->y) / (cur->x - prev->x);
|
||||
double offset = cur->y - slope * cur->x;
|
||||
double slope = (cur->y() - prev->y()) / (cur->x() - prev->x());
|
||||
double offset = cur->y() - slope * cur->x();
|
||||
int xintersect = int((y - offset ) / slope);
|
||||
if (x < xintersect)
|
||||
right++;
|
||||
else left++;
|
||||
}
|
||||
}
|
||||
prev = &(*it);
|
||||
prev = *it;
|
||||
}
|
||||
if (right % 2 && left % 2)
|
||||
return true;
|
||||
@@ -60,18 +60,18 @@ bool Shape::includesPoint(int x, int y)
|
||||
|
||||
void Shape::translate(int x, int y)
|
||||
{
|
||||
for (std::vector<Point>::iterator it = vertices.begin() ; it !=
|
||||
vertices.end(); ++it)
|
||||
for (std::vector<Point*>::iterator it = vertices.begin() ;
|
||||
it != vertices.end(); ++it)
|
||||
{
|
||||
it->x += x;
|
||||
it->y += y;
|
||||
(*it)->setX((*it)->x() + x);
|
||||
(*it)->setY((*it)->y() + y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Mesh::Mesh(Point p1, Point p2, Point p3, Point p4, int nColumns, int nRows)
|
||||
Mesh::Mesh(QPointF p1, QPointF p2, QPointF p3, QPointF p4, int nColumns, int nRows)
|
||||
: Quad(p1, p2, p3, p4), _nColumns(0), _nRows(0)
|
||||
{
|
||||
Q_ASSERT(nColumns >= 2 && nRows >= 2);
|
||||
@@ -129,21 +129,21 @@ void Mesh::addColumn()
|
||||
for (int y=0; y<nRows(); y++)
|
||||
{
|
||||
// Get left and right vertices.
|
||||
QPointF left = getVertex( _vertices2d[0] [y] ).toQPointF();
|
||||
QPointF right = getVertex( _vertices2d[nColumns()-1][y] ).toQPointF();
|
||||
QPointF left = *getVertex( _vertices2d[0] [y] );
|
||||
QPointF right = *getVertex( _vertices2d[nColumns()-1][y] );
|
||||
QPointF diff = right - left;
|
||||
|
||||
// First pass: move middle points.
|
||||
for (int x=1; x<nColumns()-1; x++)
|
||||
{
|
||||
QPointF p = getVertex( _vertices2d[x][y] ).toQPointF();
|
||||
QPointF p = *getVertex( _vertices2d[x][y] );
|
||||
p -= diff * x * leftMoveProp;
|
||||
setVertex( _vertices2d[x][y], p );
|
||||
}
|
||||
|
||||
// Create and add new point.
|
||||
QPointF newPoint = right - diff * 1.0f/nColumns();
|
||||
vertices.push_back(newPoint);
|
||||
_addVertex(newPoint);
|
||||
|
||||
// Assign new vertices 2d.
|
||||
for (int x=0; x<nColumns()-1; x++)
|
||||
@@ -179,21 +179,21 @@ void Mesh::addRow()
|
||||
for (int x=0; x<nColumns(); x++)
|
||||
{
|
||||
// Get left and right vertices.
|
||||
QPointF top = getVertex( _vertices2d[x][0] ).toQPointF();
|
||||
QPointF bottom = getVertex( _vertices2d[x][nRows()-1] ).toQPointF();
|
||||
QPointF top = *getVertex( _vertices2d[x][0] );
|
||||
QPointF bottom = *getVertex( _vertices2d[x][nRows()-1] );
|
||||
QPointF diff = bottom - top;
|
||||
|
||||
// First pass: move middle points.
|
||||
for (int y=1; y<nRows()-1; y++)
|
||||
{
|
||||
QPointF p = getVertex( _vertices2d[x][y] ).toQPointF();
|
||||
QPointF p = *getVertex( _vertices2d[x][y] );
|
||||
p -= diff * y * topMoveProp;
|
||||
setVertex( _vertices2d[x][y], p );
|
||||
}
|
||||
|
||||
// Create and add new point.
|
||||
QPointF newPoint = bottom - diff * 1.0f/nRows();
|
||||
vertices.push_back(newPoint);
|
||||
_addVertex(newPoint);
|
||||
|
||||
// Assign new vertices 2d.
|
||||
for (int y=0; y<nRows()-1; y++)
|
||||
@@ -285,10 +285,10 @@ std::vector<Quad> Mesh::getQuads() const
|
||||
for (int j=0; j<nVerticalQuads(); j++)
|
||||
{
|
||||
Quad quad(
|
||||
vertices[ _vertices2d[i] [j] ],
|
||||
vertices[ _vertices2d[i+1][j] ],
|
||||
vertices[ _vertices2d[i+1][j+1] ],
|
||||
vertices[ _vertices2d[i] [j+1] ]
|
||||
*vertices[ _vertices2d[i] [j] ],
|
||||
*vertices[ _vertices2d[i+1][j] ],
|
||||
*vertices[ _vertices2d[i+1][j+1] ],
|
||||
*vertices[ _vertices2d[i] [j+1] ]
|
||||
);
|
||||
quads.push_back(quad);
|
||||
}
|
||||
@@ -306,10 +306,10 @@ std::vector< std::vector<Quad> > Mesh::getQuads2d() const
|
||||
for (int j=0; j<nVerticalQuads(); j++)
|
||||
{
|
||||
Quad quad(
|
||||
vertices[ _vertices2d[i] [j] ],
|
||||
vertices[ _vertices2d[i+1][j] ],
|
||||
vertices[ _vertices2d[i+1][j+1] ],
|
||||
vertices[ _vertices2d[i] [j+1] ]
|
||||
*vertices[ _vertices2d[i] [j] ],
|
||||
*vertices[ _vertices2d[i+1][j] ],
|
||||
*vertices[ _vertices2d[i+1][j+1] ],
|
||||
*vertices[ _vertices2d[i] [j+1] ]
|
||||
);
|
||||
column.push_back(quad);
|
||||
}
|
||||
|
||||
@@ -31,21 +31,23 @@
|
||||
#include <QPointF>
|
||||
#include <QMetaType>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* Point (or vertex) on the 2-D canvas.
|
||||
*/
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE (qreal)
|
||||
|
||||
class Point: public QObject, public QPointF
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
|
||||
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
|
||||
Q_INVOKABLE Point(qreal x, qreal y): QPointF(x,y) {}
|
||||
Q_INVOKABLE Point(): QPointF(0,0) {}
|
||||
|
||||
signals:
|
||||
void xChanged();
|
||||
void yChanged();
|
||||
@@ -61,6 +63,11 @@ public slots:
|
||||
QPointF::setY(y);
|
||||
emit yChanged();
|
||||
}
|
||||
void setValue(const QPointF& p)
|
||||
{
|
||||
setX(p.x());
|
||||
setY(p.y());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -72,7 +79,7 @@ class Shape
|
||||
public:
|
||||
typedef std::tr1::shared_ptr<Shape> ptr;
|
||||
Shape() {}
|
||||
Shape(std::vector<Point> vertices_) :
|
||||
Shape(std::vector<Point*> vertices_) :
|
||||
vertices(vertices_)
|
||||
{}
|
||||
virtual ~Shape() {}
|
||||
@@ -81,20 +88,20 @@ public:
|
||||
|
||||
int nVertices() const { return vertices.size(); }
|
||||
|
||||
Point getVertex(int i) const
|
||||
Point* getVertex(int i) const
|
||||
{
|
||||
return vertices[i];
|
||||
}
|
||||
|
||||
void setVertex(int i, Point v)
|
||||
void setVertex(int i, QPointF v)
|
||||
{
|
||||
vertices[i] = v;
|
||||
vertices[i]->setValue(v);
|
||||
}
|
||||
|
||||
void setVertex(int i, double x, double y)
|
||||
{
|
||||
vertices[i].setX(x);
|
||||
vertices[i].setY(y);
|
||||
vertices[i]->setX(x);
|
||||
vertices[i]->setY(y);
|
||||
}
|
||||
|
||||
virtual const char * getShapeType() = 0;
|
||||
@@ -114,7 +121,15 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<Point> vertices;
|
||||
std::vector<Point*> vertices;
|
||||
|
||||
void _addVertex(const QPointF& vertex)
|
||||
{
|
||||
Point* v = new Point();
|
||||
v->setValue(vertex);
|
||||
|
||||
vertices.push_back(v);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -124,12 +139,12 @@ class Quad : public Shape
|
||||
{
|
||||
public:
|
||||
Quad() {}
|
||||
Quad(Point p1, Point p2, Point p3, Point p4)
|
||||
Quad(QPointF p1, QPointF p2, QPointF p3, QPointF p4)
|
||||
{
|
||||
vertices.push_back(p1);
|
||||
vertices.push_back(p2);
|
||||
vertices.push_back(p3);
|
||||
vertices.push_back(p4);
|
||||
_addVertex(p1);
|
||||
_addVertex(p2);
|
||||
_addVertex(p3);
|
||||
_addVertex(p4);
|
||||
}
|
||||
virtual ~Quad() {}
|
||||
|
||||
@@ -143,11 +158,11 @@ class Triangle : public Shape
|
||||
{
|
||||
public:
|
||||
Triangle() {}
|
||||
Triangle(Point p1, Point p2, Point p3)
|
||||
Triangle(QPointF p1, QPointF p2, QPointF p3)
|
||||
{
|
||||
vertices.push_back(p1);
|
||||
vertices.push_back(p2);
|
||||
vertices.push_back(p3);
|
||||
_addVertex(p1);
|
||||
_addVertex(p2);
|
||||
_addVertex(p3);
|
||||
}
|
||||
virtual ~Triangle() {}
|
||||
virtual const char * getShapeType() { return "triangle"; }
|
||||
@@ -158,7 +173,7 @@ public:
|
||||
Mesh() : _nColumns(0), _nRows(0) {
|
||||
init(1, 1);
|
||||
}
|
||||
Mesh(Point p1, Point p2, Point p3, Point p4, int nColumns=2, int nRows=2);
|
||||
Mesh(QPointF p1, QPointF p2, QPointF p3, QPointF p4, int nColumns=2, int nRows=2);
|
||||
virtual ~Mesh() {}
|
||||
|
||||
void resizeVertices2d(std::vector< std::vector<int> >& vertices2d, int nColumns, int nRows);
|
||||
|
||||
@@ -3,6 +3,7 @@ TEMPLATE = app
|
||||
HEADERS = \
|
||||
DestinationGLCanvas.h \
|
||||
Facade.h \
|
||||
Layer.h \
|
||||
MainWindow.h \
|
||||
Mapper.h \
|
||||
MapperGLCanvas.h \
|
||||
@@ -20,6 +21,7 @@ SOURCES = \
|
||||
Controller.cpp \
|
||||
DestinationGLCanvas.cpp \
|
||||
Facade.cpp \
|
||||
Layer.cpp \
|
||||
MainWindow.cpp \
|
||||
Mapper.cpp \
|
||||
MapperGLCanvas.cpp \
|
||||
@@ -27,6 +29,7 @@ SOURCES = \
|
||||
NameAllocator.cpp \
|
||||
ProjectReader.cpp \
|
||||
ProjectWriter.cpp \
|
||||
Shape.cpp \
|
||||
SourceGLCanvas.cpp \
|
||||
Util.cpp \
|
||||
main.cpp
|
||||
|
||||
Reference in New Issue
Block a user