mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Merge branch 'statesaving' into translation
This commit is contained in:
+5
-5
@@ -17,11 +17,11 @@ prototypes/wx-04-gst/run
|
||||
Debug/
|
||||
Release/
|
||||
libremapping
|
||||
moc_DestinationGLCanvas.cpp
|
||||
moc_MapperGLCanvas.cpp
|
||||
moc_MainWindow.cpp
|
||||
moc_SourceGLCanvas.cpp
|
||||
moc_*.cpp
|
||||
prototypes/gst/
|
||||
prototypes/wx-02-input-output/run
|
||||
qrc_libremapping.cpp
|
||||
qrc_*.cpp
|
||||
qteditorfactory.moc
|
||||
qtpropertymanager.moc
|
||||
qttreepropertybrowser.moc
|
||||
html/
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
LibreMapping known bugs
|
||||
=======================
|
||||
|
||||
|
||||
* segfaults if OSC receiving port is busy
|
||||
* should ask for confirmation when we quit if the project has not been saved.
|
||||
* cannot load state saving
|
||||
* cannot delete mappings
|
||||
* cannot delete paints
|
||||
* cannot remove points in meshes
|
||||
|
||||
|
||||
+4
-1
@@ -34,20 +34,23 @@ bool Facade::clearProject()
|
||||
|
||||
bool Facade::createImagePaint(const char *paint_id, const char *uri)
|
||||
{
|
||||
std::cout << "TODO: Facade::createImagePaint" << std::endl;
|
||||
}
|
||||
|
||||
bool Facade::updateImagePaintUri(const char *paint_id, const char *uri)
|
||||
{
|
||||
std::cout << "TODO: Facade::updateImagePaintUri" << std::endl;
|
||||
}
|
||||
|
||||
bool Facade::createMeshTextureMapping(const char *mapping_id, const char *paint_id,
|
||||
int n_rows, int n_cols,
|
||||
const QList<QPointF> &src, const QList<QPointF> &dst)
|
||||
{
|
||||
std::cout << "TODO: Facade::createMeshTextureMapping" << std::endl;
|
||||
}
|
||||
|
||||
bool Facade::createTriangleTextureMapping(const char *mapping_id, const char *paint_id,
|
||||
const QList<QPointF> &src, const QList<QPointF> &dst)
|
||||
{
|
||||
std::cout << "TODO: Facade::createTriangleTextureMapping" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -550,7 +550,7 @@ void MainWindow::createStatusBar()
|
||||
|
||||
void MainWindow::readSettings()
|
||||
{
|
||||
QSettings settings("OIF", "Libremapping");
|
||||
QSettings settings("LibreMapping", "LibreMapping");
|
||||
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
|
||||
@@ -561,7 +561,7 @@ void MainWindow::readSettings()
|
||||
|
||||
void MainWindow::writeSettings()
|
||||
{
|
||||
QSettings settings("OIF", "Libremapping");
|
||||
QSettings settings("LibreMapping", "LibreMapping");
|
||||
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
settings.setValue("mainSplitter", mainSplitter->saveState());
|
||||
@@ -784,7 +784,7 @@ void MainWindow::startOscReceiver()
|
||||
int port = config_osc_receive_port;
|
||||
std::ostringstream os;
|
||||
os << port;
|
||||
osc_interface.reset(new OscInterface(this, os.str()));
|
||||
osc_interface.reset(new OscInterface(os.str()));
|
||||
if (port != 0)
|
||||
{
|
||||
osc_interface->start();
|
||||
@@ -798,7 +798,7 @@ void MainWindow::startOscReceiver()
|
||||
void MainWindow::pollOscInterface()
|
||||
{
|
||||
#ifdef HAVE_OSC
|
||||
osc_interface->consume_commands();
|
||||
osc_interface->consume_commands(*_facade);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+73
-26
@@ -21,14 +21,14 @@
|
||||
*/
|
||||
|
||||
#include "OscInterface.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Facade.h"
|
||||
#include <QVariant>
|
||||
|
||||
OscInterface::OscInterface(
|
||||
MainWindow* owner,
|
||||
// MainWindow* owner,
|
||||
const std::string &listen_port) :
|
||||
receiver_(listen_port),
|
||||
owner_(owner),
|
||||
// owner_(owner),
|
||||
messaging_queue_()
|
||||
{
|
||||
//if (listen_port != OSC_PORT_NONE)
|
||||
@@ -38,7 +38,7 @@ OscInterface::OscInterface(
|
||||
std::cout << "Listening osc.udp://localhost:" << listen_port << std::endl;
|
||||
// receiver_.addHandler("/ping", "", ping_cb, this);
|
||||
// receiver_.addHandler("/pong", "", pong_cb, this);
|
||||
// receiver_.addHandler("/image/path", "s", image_path_cb, this);
|
||||
//receiver_.addHandler("/image/path", "ss", image_path_cb, this);
|
||||
receiver_.addHandler(NULL, NULL, genericHandler, this);
|
||||
}
|
||||
}
|
||||
@@ -77,35 +77,17 @@ int OscInterface::ping_cb(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OscInterface::image_path_cb(
|
||||
const char *path,
|
||||
const char * /*types*/,
|
||||
lo_arg **argv,
|
||||
int /*argc*/,
|
||||
void * /*data*/,
|
||||
void *user_data)
|
||||
{
|
||||
OscInterface* context = static_cast<OscInterface*>(user_data);
|
||||
std::string file_name(static_cast<const char*>(&argv[0]->s));
|
||||
//if (context->is_verbose())
|
||||
std::cout << "Got " << path << " " << file_name << std::endl;
|
||||
QVariantList message;
|
||||
message.append(QVariant(QString("image/path")));
|
||||
message.append(QVariant(QString(file_name.c_str())));
|
||||
context->push_command(message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OscInterface::push_command(QVariantList command)
|
||||
{
|
||||
messaging_queue_.push(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes action!
|
||||
*
|
||||
* Should be called when it's time to take action, before rendering a frame, for example.
|
||||
*/
|
||||
void OscInterface::consume_commands()
|
||||
void OscInterface::consume_commands(Facade &facade)
|
||||
{
|
||||
bool success = true;
|
||||
while (success)
|
||||
@@ -117,12 +99,13 @@ void OscInterface::consume_commands()
|
||||
//if (is_verbose())
|
||||
// std::cout << __FUNCTION__ << ": apply " <<
|
||||
// command.first().toString().toStdString() << std::endl;
|
||||
owner_->applyOscCommand(command);
|
||||
this->applyOscCommand(facade, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Starts listening if enabled
|
||||
/**
|
||||
* Starts listening if enabled
|
||||
*/
|
||||
void OscInterface::start()
|
||||
{
|
||||
@@ -174,3 +157,67 @@ int OscInterface::genericHandler(const char *path,
|
||||
context->push_command(message);
|
||||
return 0; // handled
|
||||
}
|
||||
|
||||
static void printCommand(QVariantList &command)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
void OscInterface::applyOscCommand(Facade &facade, QVariantList & command)
|
||||
{
|
||||
bool VERBOSE = true;
|
||||
|
||||
if (VERBOSE)
|
||||
{
|
||||
std::cout << "OscInterface::applyOscCommand: Receive OSC: " << std::endl;
|
||||
printCommand(command);
|
||||
}
|
||||
|
||||
// The two first QVariant objects are: path, typeTags
|
||||
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 == "ss")
|
||||
{
|
||||
std::string paint_id = command.at(2).toString().toStdString();
|
||||
std::string image_uri = command.at(3).toString().toStdString();
|
||||
//std::cout << "TODO load /image/uri " << image_id << " " << image_uri << std::endl;
|
||||
facade.updateImagePaintUri(paint_id.c_str(), image_uri.c_str());
|
||||
}
|
||||
|
||||
//else if (path == "/add/quad")
|
||||
// addQuad();
|
||||
//else if (path == "/add/triangle")
|
||||
// addTriangle();
|
||||
//else if (path == "/project/save")
|
||||
// save();
|
||||
//else if (path == "/project/open")
|
||||
// open();
|
||||
}
|
||||
|
||||
+16
-8
@@ -28,7 +28,7 @@
|
||||
#include "OscReceiver.h"
|
||||
#include <QVariant>
|
||||
|
||||
class MainWindow; // forward decl
|
||||
class Facade; // forward decl
|
||||
|
||||
/**
|
||||
* Open Sound Control sending and receiving for LibreMapping.
|
||||
@@ -38,20 +38,23 @@ class OscInterface
|
||||
public:
|
||||
typedef std::tr1::shared_ptr<OscInterface> ptr;
|
||||
OscInterface(
|
||||
MainWindow* owner,
|
||||
//MainWindow* owner,
|
||||
const std::string &listen_port);
|
||||
~OscInterface() {}
|
||||
void start();
|
||||
void consume_commands();
|
||||
bool is_verbose() { return false; }
|
||||
/**
|
||||
* Call this method from the main thread.
|
||||
*
|
||||
* Each message is stored as a QVariantList.
|
||||
* <path> <typeTags> [args]
|
||||
*/
|
||||
void consume_commands(Facade &facade);
|
||||
private:
|
||||
bool is_verbose() { return false; }
|
||||
void push_command(QVariantList command);
|
||||
/**
|
||||
* OSC callback
|
||||
*/
|
||||
static int image_path_cb(const char *path,
|
||||
const char *types, lo_arg **argv,
|
||||
int argc, void *data, void *user_data);
|
||||
static int ping_cb(const char *path,
|
||||
const char *types, lo_arg **argv,
|
||||
int argc, void *data, void *user_data);
|
||||
@@ -64,8 +67,13 @@ class OscInterface
|
||||
|
||||
bool receiving_enabled_;
|
||||
OscReceiver receiver_;
|
||||
MainWindow* owner_;
|
||||
//MainWindow* owner_;
|
||||
ConcurrentQueue<QVariantList> messaging_queue_;
|
||||
/*
|
||||
* In the main thread, handles the messages.
|
||||
*/
|
||||
void applyOscCommand(Facade &facade, QVariantList & command);
|
||||
};
|
||||
|
||||
|
||||
#endif /* include guard */
|
||||
|
||||
Reference in New Issue
Block a user