Merge branch 'develop' into osc-fix-july-2014
@@ -19,6 +19,11 @@
|
||||
|
||||
#include "MM.h"
|
||||
|
||||
const QString MM::VERSION = "0.1.1";
|
||||
const QString MM::FILE_EXTENSION = "mmp";
|
||||
const QString MM::VIDEO_FILES_FILTER = "*.mov *.mp4 *.avi *.ogg *.ogv *.mpeg *.mpeg1 *.mpeg4 *.mpg *.mpg2 *.mp2 *.mjpq *.mjp *.wmv";
|
||||
const QString MM::IMAGE_FILES_FILTER = "*.jpg *.jpeg *.gif *.png *.tiff *.tif *.bmp";
|
||||
|
||||
const QColor MM::WHITE("#f6f5f5");
|
||||
const QColor MM::BLUE_GRAY("#323541");
|
||||
const QColor MM::DARK_GRAY("#272a36");
|
||||
|
||||
@@ -28,9 +28,17 @@
|
||||
class MM
|
||||
{
|
||||
public:
|
||||
// General.
|
||||
static const QString VERSION;
|
||||
static const QString FILE_EXTENSION;
|
||||
static const QString VIDEO_FILES_FILTER;
|
||||
static const QString IMAGE_FILES_FILTER;
|
||||
|
||||
// GUI.
|
||||
static const int DEFAULT_WINDOW_WIDTH = 640;
|
||||
static const int DEFAULT_WINDOW_HEIGHT = 480;
|
||||
static const int TOP_TOOLBAR_ICON_SIZE = 64;
|
||||
static const int BOTTOM_TOOLBAR_ICON_SIZE = 32;
|
||||
|
||||
// Style.
|
||||
static const QColor WHITE;
|
||||
|
||||
@@ -43,12 +43,10 @@ MainWindow::MainWindow()
|
||||
_hasCurrentMapping = false;
|
||||
currentSelectedItem = NULL;
|
||||
|
||||
// Create everything.
|
||||
videoTimer = new QTimer(this);
|
||||
videoTimer->setInterval(1000/30);
|
||||
connect(videoTimer, SIGNAL(timeout()), this, SLOT(updateCanvases()));
|
||||
videoTimer->start();
|
||||
// Play state.
|
||||
_isPlaying = false;
|
||||
|
||||
// Create everything.
|
||||
createLayout();
|
||||
createActions();
|
||||
createMenus();
|
||||
@@ -65,6 +63,12 @@ MainWindow::MainWindow()
|
||||
// Defaults.
|
||||
//setWindowIcon(QIcon(":/images/icon.png"));
|
||||
setCurrentFile("");
|
||||
|
||||
// Create and start timer.
|
||||
videoTimer = new QTimer(this);
|
||||
videoTimer->setInterval(1000/30);
|
||||
connect(videoTimer, SIGNAL(timeout()), this, SLOT(updateCanvases()));
|
||||
videoTimer->start();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -174,7 +178,15 @@ void MainWindow::handleItemDoubleClicked(QListWidgetItem* item)
|
||||
// Restart video playback. XXX Hack
|
||||
videoTimer->start();
|
||||
if (!fileName.isEmpty())
|
||||
importMediaFile(fileName, paint);
|
||||
importMediaFile(fileName, paint, false);
|
||||
}
|
||||
if (paint->getType() == "image") {
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Import media source file"), ".");
|
||||
// Restart video playback. XXX Hack
|
||||
videoTimer->start();
|
||||
if (!fileName.isEmpty())
|
||||
importMediaFile(fileName, paint, true);
|
||||
}
|
||||
else if (paint->getType() == "color") {
|
||||
// Pop-up color-choosing dialog to choose color paint.
|
||||
@@ -235,9 +247,8 @@ void MainWindow::open()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open project"),
|
||||
".", // TODO : change this to previous used one, if any
|
||||
//tr("MapMap files (*.%1)", MAPMAP_EXTENSION));
|
||||
tr("All files (*)"));
|
||||
".",
|
||||
tr("MapMap files (*.%1)").arg(MM::FILE_EXTENSION));
|
||||
if (! fileName.isEmpty())
|
||||
loadFile(fileName);
|
||||
}
|
||||
@@ -268,8 +279,7 @@ bool MainWindow::saveAs()
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save project"),
|
||||
".",
|
||||
tr("MapMap files (*.%1)", MAPMAP_EXTENSION)
|
||||
);
|
||||
tr("MapMap files (*.%1)").arg(MM::FILE_EXTENSION));
|
||||
|
||||
// Restart video playback. XXX Hack
|
||||
videoTimer->start();
|
||||
@@ -277,19 +287,19 @@ bool MainWindow::saveAs()
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
|
||||
if (! fileName.endsWith(MAPMAP_EXTENSION))
|
||||
if (! fileName.endsWith(MM::FILE_EXTENSION))
|
||||
{
|
||||
std::cout << "filename doesn't end with expected extension: " <<
|
||||
fileName.toStdString() << std::endl;
|
||||
fileName.append(".");
|
||||
fileName.append(MAPMAP_EXTENSION);
|
||||
fileName.append(MM::FILE_EXTENSION);
|
||||
}
|
||||
|
||||
// Save to filename.
|
||||
return saveFile(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::import()
|
||||
void MainWindow::importVideo()
|
||||
{
|
||||
// Stop video playback to avoid lags. XXX Hack
|
||||
videoTimer->stop();
|
||||
@@ -297,13 +307,29 @@ void MainWindow::import()
|
||||
// Pop-up file-choosing dialog to choose media file.
|
||||
// TODO: restrict the type of files that can be imported
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Import media source file"), ".");
|
||||
tr("Import media source file"), ".", tr("Video files (%1);;All files (*)").arg(MM::VIDEO_FILES_FILTER));
|
||||
// Restart video playback. XXX Hack
|
||||
videoTimer->start();
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
importMediaFile(fileName, std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), false);
|
||||
}
|
||||
|
||||
void MainWindow::importImage()
|
||||
{
|
||||
// Stop video playback to avoid lags. XXX Hack
|
||||
videoTimer->stop();
|
||||
|
||||
// Pop-up file-choosing dialog to choose media file.
|
||||
// TODO: restrict the type of files that can be imported
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Import media source file"), ".", tr("Image files (%1);;All files (*)").arg(MM::IMAGE_FILES_FILTER));
|
||||
|
||||
// Restart video playback. XXX Hack
|
||||
videoTimer->start();
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
importMediaFile(fileName, std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)));
|
||||
importMediaFile(fileName, std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), true);
|
||||
}
|
||||
|
||||
void MainWindow::addColor()
|
||||
@@ -420,6 +446,37 @@ void MainWindow::addEllipse()
|
||||
addMappingItem(mappingId);
|
||||
}
|
||||
|
||||
void MainWindow::play()
|
||||
{
|
||||
// Update buttons.
|
||||
playAction->setVisible(false);
|
||||
pauseAction->setVisible(true);
|
||||
_isPlaying = true;
|
||||
|
||||
// Start all paints.
|
||||
for (int i=0; i<mappingManager->nPaints(); i++)
|
||||
mappingManager->getPaint(i)->play();
|
||||
}
|
||||
|
||||
void MainWindow::pause()
|
||||
{
|
||||
// Update buttons.
|
||||
playAction->setVisible(true);
|
||||
pauseAction->setVisible(false);
|
||||
_isPlaying = false;
|
||||
|
||||
// Pause all paints.
|
||||
for (int i=0; i<mappingManager->nPaints(); i++)
|
||||
mappingManager->getPaint(i)->pause();
|
||||
}
|
||||
|
||||
void MainWindow::rewind()
|
||||
{
|
||||
// Rewind all paints.
|
||||
for (int i=0; i<mappingManager->nPaints(); i++)
|
||||
mappingManager->getPaint(i)->rewind();
|
||||
}
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
// Stop video playback to avoid lags. XXX Hack
|
||||
@@ -427,9 +484,7 @@ void MainWindow::about()
|
||||
|
||||
// Pop-up about dialog.
|
||||
QMessageBox::about(this, tr("About MapMap"),
|
||||
tr("<h2>MapMap "
|
||||
MAPMAP_VERSION
|
||||
"</h2>"
|
||||
tr("<h2>MapMap %1</h2>"
|
||||
"<p>Copyright © 2013 Sofian Audry, Alexandre Quessy, Julien Keable, "
|
||||
"Mike Latona and Vasilis Liaskovitis."
|
||||
"<p>MapMap is a free software for video mapping. "
|
||||
@@ -447,7 +502,7 @@ void MainWindow::about()
|
||||
"This project was made possible by the support of the International Organization of "
|
||||
"La Francophonie."
|
||||
"http://www.francophonie.org/"
|
||||
));
|
||||
).arg(MM::VERSION));
|
||||
|
||||
// Restart video playback. XXX Hack
|
||||
videoTimer->start();
|
||||
@@ -520,7 +575,7 @@ bool MainWindow::clearProject()
|
||||
return true;
|
||||
}
|
||||
|
||||
uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, Paint::ptr oldPaint)
|
||||
uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, Paint::ptr oldPaint, bool isImage)
|
||||
{
|
||||
// Cannot create image with already existing id.
|
||||
if (Paint::getUidAllocator().exists(paintId))
|
||||
@@ -528,14 +583,17 @@ uid MainWindow::createMediaPaint(uid paintId, QString uri, float x, float y, Pai
|
||||
|
||||
else
|
||||
{
|
||||
Media* img = new Media(uri, paintId);
|
||||
// Image* img = new Image(uri, paintId);
|
||||
Texture* tex = 0;
|
||||
if (isImage)
|
||||
tex = new Image(uri, paintId);
|
||||
else
|
||||
tex = new Media(uri, paintId);
|
||||
|
||||
// Create new image with corresponding ID.
|
||||
img->setPosition(x, y);
|
||||
tex->setPosition(x, y);
|
||||
|
||||
// Add it to the manager.
|
||||
Paint::ptr paint(img);
|
||||
Paint::ptr paint(tex);
|
||||
|
||||
// Add paint to model and return its uid.
|
||||
uid id = mappingManager->addPaint(paint);
|
||||
@@ -665,7 +723,7 @@ uid MainWindow::createEllipseTextureMapping(uid mappingId,
|
||||
Paint::ptr paint = mappingManager->getPaintById(paintId);
|
||||
Q_ASSERT(src.size() == 5 && dst.size() == 5);
|
||||
|
||||
Shape::ptr inputEllipse( new Ellipse(src[0], src[1], src[2], dst[3], dst[4]));
|
||||
Shape::ptr inputEllipse( new Ellipse(src[0], src[1], src[2], src[3], src[4]));
|
||||
Shape::ptr outputEllipse(new Ellipse(dst[0], dst[1], dst[2], dst[3], dst[4]));
|
||||
|
||||
// Add it to the manager.
|
||||
@@ -896,47 +954,61 @@ void MainWindow::createActions()
|
||||
{
|
||||
// New.
|
||||
newAction = new QAction(tr("&New"), this);
|
||||
newAction->setIcon(QIcon(":/images/document-new-4.png"));
|
||||
newAction->setIcon(QIcon(":/new"));
|
||||
newAction->setShortcut(QKeySequence::New);
|
||||
newAction->setStatusTip(tr("Create a new project"));
|
||||
newAction->setIconVisibleInMenu(false);
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
|
||||
|
||||
// Open.
|
||||
openAction = new QAction(tr("&Open..."), this);
|
||||
openAction->setIcon(QIcon(":/images/document-open-3.png"));
|
||||
openAction->setIcon(QIcon(":/open"));
|
||||
openAction->setShortcut(QKeySequence::Open);
|
||||
openAction->setStatusTip(tr("Open an existing project"));
|
||||
openAction->setIconVisibleInMenu(false);
|
||||
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||
|
||||
// Save.
|
||||
saveAction = new QAction(tr("&Save"), this);
|
||||
saveAction->setIcon(QIcon(":/images/document-save-2.png"));
|
||||
saveAction->setIcon(QIcon(":/save"));
|
||||
saveAction->setShortcut(QKeySequence::Save);
|
||||
saveAction->setStatusTip(tr("Save the project"));
|
||||
saveAction->setIconVisibleInMenu(false);
|
||||
connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
|
||||
|
||||
// Save as.
|
||||
saveAsAction = new QAction(tr("Save &As..."), this);
|
||||
saveAsAction->setIcon(QIcon(":/images/document-save-as-2.png"));
|
||||
saveAsAction->setIcon(QIcon(":/save-as"));
|
||||
saveAsAction->setStatusTip(tr("Save the project as..."));
|
||||
saveAsAction->setIconVisibleInMenu(false);
|
||||
connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
|
||||
|
||||
// Import media.
|
||||
importAction = new QAction(tr("&Import media source file..."), this);
|
||||
importAction->setIcon(QIcon(":/images/document-import-2.png"));
|
||||
importAction->setStatusTip(tr("Import a media source file..."));
|
||||
connect(importAction, SIGNAL(triggered()), this, SLOT(import()));
|
||||
// Import video.
|
||||
importVideoAction = new QAction(tr("&Import media source file..."), this);
|
||||
importVideoAction->setIcon(QIcon(":/add-video"));
|
||||
importVideoAction->setStatusTip(tr("Import a media source file..."));
|
||||
importVideoAction->setIconVisibleInMenu(false);
|
||||
connect(importVideoAction, SIGNAL(triggered()), this, SLOT(importVideo()));
|
||||
|
||||
// Import imiage.
|
||||
importImageAction = new QAction(tr("&Import media source file..."), this);
|
||||
importImageAction->setIcon(QIcon(":/add-image"));
|
||||
importImageAction->setStatusTip(tr("Import a media source file..."));
|
||||
importImageAction->setIconVisibleInMenu(false);
|
||||
connect(importImageAction, SIGNAL(triggered()), this, SLOT(importImage()));
|
||||
|
||||
// Add color.
|
||||
addColorAction = new QAction(tr("Add &Color paint..."), this);
|
||||
addColorAction->setIcon(QIcon(":/images/colorize.png"));
|
||||
addColorAction->setIcon(QIcon(":/add-color"));
|
||||
addColorAction->setStatusTip(tr("Add a color paint..."));
|
||||
addColorAction->setIconVisibleInMenu(false);
|
||||
connect(addColorAction, SIGNAL(triggered()), this, SLOT(addColor()));
|
||||
|
||||
// Exit/quit.
|
||||
exitAction = new QAction(tr("E&xit"), this);
|
||||
exitAction->setShortcut(tr("Ctrl+Q"));
|
||||
exitAction->setStatusTip(tr("Exit the application"));
|
||||
exitAction->setIconVisibleInMenu(false);
|
||||
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
||||
|
||||
// cutAction = new QAction(tr("Cu&t"), this);
|
||||
@@ -965,42 +1037,75 @@ void MainWindow::createActions()
|
||||
// About.
|
||||
aboutAction = new QAction(tr("&About"), this);
|
||||
aboutAction->setStatusTip(tr("Show the application's About box"));
|
||||
aboutAction->setIconVisibleInMenu(false);
|
||||
connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||
|
||||
// Delete.
|
||||
deleteAction = new QAction(tr("Delete"), this);
|
||||
deleteAction->setShortcut(tr("CTRL+DEL"));
|
||||
deleteAction->setStatusTip(tr("Delete item"));
|
||||
deleteAction->setIconVisibleInMenu(false);
|
||||
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem()));
|
||||
|
||||
// Add quad/mesh.
|
||||
addMeshAction = new QAction(tr("Add Quad/&Mesh"), this);
|
||||
addMeshAction->setShortcut(tr("CTRL+M"));
|
||||
addMeshAction->setIcon(QIcon(":/images/draw-rectangle-2.png"));
|
||||
addMeshAction->setIcon(QIcon(":/add-mesh"));
|
||||
addMeshAction->setStatusTip(tr("Add quad/mesh"));
|
||||
addMeshAction->setIconVisibleInMenu(false);
|
||||
connect(addMeshAction, SIGNAL(triggered()), this, SLOT(addMesh()));
|
||||
addMeshAction->setEnabled(false);
|
||||
|
||||
// Add triangle.
|
||||
addTriangleAction = new QAction(tr("Add &Triangle"), this);
|
||||
addTriangleAction->setShortcut(tr("CTRL+T"));
|
||||
addTriangleAction->setIcon(QIcon(":/images/draw-triangle.png"));
|
||||
addTriangleAction->setIcon(QIcon(":/add-triangle"));
|
||||
addTriangleAction->setStatusTip(tr("Add triangle"));
|
||||
addTriangleAction->setIconVisibleInMenu(false);
|
||||
connect(addTriangleAction, SIGNAL(triggered()), this, SLOT(addTriangle()));
|
||||
addTriangleAction->setEnabled(false);
|
||||
|
||||
// Add ellipse.
|
||||
addEllipseAction = new QAction(tr("Add &Ellipse"), this);
|
||||
addEllipseAction->setShortcut(tr("CTRL+E"));
|
||||
addEllipseAction->setIcon(QIcon(":/images/draw-ellipse-2.png"));
|
||||
addEllipseAction->setIcon(QIcon(":/add-ellipse"));
|
||||
addEllipseAction->setStatusTip(tr("Add ellipse"));
|
||||
addEllipseAction->setIconVisibleInMenu(false);
|
||||
connect(addEllipseAction, SIGNAL(triggered()), this, SLOT(addEllipse()));
|
||||
addEllipseAction->setEnabled(false);
|
||||
|
||||
// Play.
|
||||
playAction = new QAction(tr("Play"), this);
|
||||
playAction->setShortcut(tr("CTRL+P"));
|
||||
playAction->setIcon(QIcon(":/play"));
|
||||
playAction->setStatusTip(tr("Play"));
|
||||
playAction->setIconVisibleInMenu(false);
|
||||
connect(playAction, SIGNAL(triggered()), this, SLOT(play()));
|
||||
playAction->setVisible(true);
|
||||
|
||||
// Pause.
|
||||
pauseAction = new QAction(tr("Pause"), this);
|
||||
pauseAction->setShortcut(tr("CTRL+P"));
|
||||
pauseAction->setIcon(QIcon(":/pause"));
|
||||
pauseAction->setStatusTip(tr("Pause"));
|
||||
pauseAction->setIconVisibleInMenu(false);
|
||||
connect(pauseAction, SIGNAL(triggered()), this, SLOT(pause()));
|
||||
pauseAction->setVisible(false);
|
||||
|
||||
// Pause.
|
||||
rewindAction = new QAction(tr("Rewind"), this);
|
||||
rewindAction->setShortcut(tr("CTRL+R"));
|
||||
rewindAction->setIcon(QIcon(":/rewind"));
|
||||
rewindAction->setStatusTip(tr("Rewind"));
|
||||
rewindAction->setIconVisibleInMenu(false);
|
||||
connect(rewindAction, SIGNAL(triggered()), this, SLOT(rewind()));
|
||||
|
||||
// Toggle display of output window.
|
||||
displayOutputWindow = new QAction(tr("&Display output window"), this);
|
||||
displayOutputWindow->setShortcut(tr("Ctrl+D"));
|
||||
displayOutputWindow->setIcon(QIcon(":/output-window"));
|
||||
displayOutputWindow->setStatusTip(tr("Display output window"));
|
||||
displayOutputWindow->setIconVisibleInMenu(false);
|
||||
displayOutputWindow->setCheckable(true);
|
||||
displayOutputWindow->setChecked(true);
|
||||
// Manage show/hide of GL output window.
|
||||
@@ -1010,8 +1115,10 @@ void MainWindow::createActions()
|
||||
|
||||
// Toggle display of output window.
|
||||
outputWindowFullScreen = new QAction(tr("&Full screen"), this);
|
||||
outputWindowFullScreen->setIcon(QIcon(":/fullscreen"));
|
||||
outputWindowFullScreen->setShortcut(tr("Ctrl+F"));
|
||||
outputWindowFullScreen->setStatusTip(tr("Full screen"));
|
||||
outputWindowFullScreen->setIconVisibleInMenu(false);
|
||||
outputWindowFullScreen->setCheckable(true);
|
||||
outputWindowFullScreen->setChecked(false);
|
||||
// Manage fullscreen mode for output window.
|
||||
@@ -1021,11 +1128,12 @@ void MainWindow::createActions()
|
||||
// Output window should be displayed for full screen option to be available.
|
||||
connect(displayOutputWindow, SIGNAL(toggled(bool)), outputWindowFullScreen, SLOT(setEnabled(bool)));
|
||||
|
||||
|
||||
// Toggle display of canvas controls.
|
||||
displayCanvasControls = new QAction(tr("&Display canvas controls"), this);
|
||||
// displayCanvasControls->setShortcut(tr("Ctrl+E"));
|
||||
displayCanvasControls->setIcon(QIcon(":/control-points"));
|
||||
displayCanvasControls->setStatusTip(tr("Display canvas controls"));
|
||||
displayCanvasControls->setIconVisibleInMenu(false);
|
||||
displayCanvasControls->setCheckable(true);
|
||||
displayCanvasControls->setChecked(true);
|
||||
// Manage show/hide of canvas controls.
|
||||
@@ -1052,7 +1160,8 @@ void MainWindow::createMenus()
|
||||
fileMenu->addAction(saveAction);
|
||||
fileMenu->addAction(saveAsAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(importAction);
|
||||
fileMenu->addAction(importVideoAction);
|
||||
fileMenu->addAction(importImageAction);
|
||||
fileMenu->addAction(addColorAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAction);
|
||||
@@ -1070,6 +1179,12 @@ void MainWindow::createMenus()
|
||||
viewMenu->addAction(outputWindowFullScreen);
|
||||
viewMenu->addAction(displayCanvasControls);
|
||||
|
||||
// Run.
|
||||
runMenu = menuBar->addMenu(tr("&Run"));
|
||||
runMenu->addAction(playAction);
|
||||
runMenu->addAction(pauseAction);
|
||||
runMenu->addAction(rewindAction);
|
||||
|
||||
// selectSubMenu = editMenu->addMenu(tr("&Select"));
|
||||
// selectSubMenu->addAction(selectRowAction);
|
||||
// selectSubMenu->addAction(selectColumnAction);
|
||||
@@ -1103,17 +1218,43 @@ void MainWindow::createContextMenu()
|
||||
|
||||
void MainWindow::createToolBars()
|
||||
{
|
||||
fileToolBar = addToolBar(tr("&File"));
|
||||
fileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
fileToolBar->addAction(importAction);
|
||||
fileToolBar->addAction(addColorAction);
|
||||
fileToolBar->addAction(newAction);
|
||||
fileToolBar->addAction(openAction);
|
||||
fileToolBar->addAction(saveAction);
|
||||
fileToolBar->addSeparator();
|
||||
fileToolBar->addAction(addMeshAction);
|
||||
fileToolBar->addAction(addTriangleAction);
|
||||
fileToolBar->addAction(addEllipseAction);
|
||||
mainToolBar = addToolBar(tr("&File"));
|
||||
mainToolBar->setIconSize(QSize(MM::TOP_TOOLBAR_ICON_SIZE, MM::TOP_TOOLBAR_ICON_SIZE));
|
||||
mainToolBar->setMovable(false);
|
||||
mainToolBar->addAction(importVideoAction);
|
||||
mainToolBar->addAction(importImageAction);
|
||||
mainToolBar->addAction(addColorAction);
|
||||
mainToolBar->addAction(newAction);
|
||||
mainToolBar->addAction(openAction);
|
||||
mainToolBar->addAction(saveAction);
|
||||
|
||||
mainToolBar->addSeparator();
|
||||
|
||||
mainToolBar->addAction(addMeshAction);
|
||||
mainToolBar->addAction(addTriangleAction);
|
||||
mainToolBar->addAction(addEllipseAction);
|
||||
|
||||
mainToolBar->addSeparator();
|
||||
|
||||
mainToolBar->addAction(displayOutputWindow);
|
||||
mainToolBar->addAction(outputWindowFullScreen);
|
||||
mainToolBar->addAction(displayCanvasControls);
|
||||
|
||||
runToolBar = addToolBar(tr("&Run"));
|
||||
runToolBar->setIconSize(QSize(MM::TOP_TOOLBAR_ICON_SIZE, MM::TOP_TOOLBAR_ICON_SIZE));
|
||||
runToolBar->setMovable(false);
|
||||
// XXX: style hack: dummy expanding widget allows the placement of toolbar at the top right
|
||||
// From: http://www.qtcentre.org/threads/9102-QToolbar-setContentsMargins
|
||||
QWidget* spacer = new QWidget(runToolBar);
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
runToolBar->addWidget(spacer);
|
||||
runToolBar->addAction(playAction);
|
||||
runToolBar->addAction(pauseAction);
|
||||
runToolBar->addAction(rewindAction);
|
||||
|
||||
// Add toolbars.
|
||||
addToolBar(Qt::TopToolBarArea, mainToolBar);
|
||||
addToolBar(Qt::TopToolBarArea, runToolBar);
|
||||
|
||||
// editToolBar = addToolBar(tr("&Edit"));
|
||||
// editToolBar->addAction(cutAction);
|
||||
@@ -1265,7 +1406,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
||||
// {
|
||||
// }
|
||||
|
||||
bool MainWindow::importMediaFile(const QString &fileName, Paint::ptr oldPaint)
|
||||
bool MainWindow::importMediaFile(const QString &fileName, Paint::ptr oldPaint, bool isImage)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
@@ -1279,12 +1420,17 @@ bool MainWindow::importMediaFile(const QString &fileName, Paint::ptr oldPaint)
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
// Add media file to model.
|
||||
uint mediaId = createMediaPaint(NULL_UID, fileName, 0, 0, oldPaint);
|
||||
uint mediaId = createMediaPaint(NULL_UID, fileName, 0, 0, oldPaint, isImage);
|
||||
|
||||
// Initialize position (center).
|
||||
std::tr1::shared_ptr<Media> media = std::tr1::static_pointer_cast<Media>(mappingManager->getPaintById(mediaId));
|
||||
Q_CHECK_PTR(media);
|
||||
|
||||
if (_isPlaying)
|
||||
media->play();
|
||||
else
|
||||
media->pause();
|
||||
|
||||
media->setPosition((sourceCanvas->width() - media->getWidth() ) / 2.0f,
|
||||
(sourceCanvas->height() - media->getHeight()) / 2.0f );
|
||||
|
||||
@@ -1306,6 +1452,12 @@ bool MainWindow::addColorPaint(const QColor& color, Paint::ptr oldPaint)
|
||||
std::tr1::shared_ptr<Color> colorPaint = std::tr1::static_pointer_cast<Color>(mappingManager->getPaintById(colorId));
|
||||
Q_CHECK_PTR(colorPaint);
|
||||
|
||||
// Does not do anything...
|
||||
if (_isPlaying)
|
||||
colorPaint->play();
|
||||
else
|
||||
colorPaint->pause();
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
statusBar()->showMessage(tr("Color paint added"), 2000);
|
||||
@@ -1348,7 +1500,7 @@ void MainWindow::addMappingItem(uid mappingId)
|
||||
// Add mapper.
|
||||
// XXX hardcoded for textures
|
||||
std::tr1::shared_ptr<TextureMapping> textureMapping;
|
||||
if (paintType == "media")
|
||||
if (paintType == "media" || paintType == "image")
|
||||
{
|
||||
textureMapping = std::tr1::static_pointer_cast<TextureMapping>(mapping);
|
||||
Q_CHECK_PTR(textureMapping);
|
||||
@@ -1363,7 +1515,7 @@ void MainWindow::addMappingItem(uid mappingId)
|
||||
if (shapeType == "triangle")
|
||||
{
|
||||
label = QString("Triangle %1").arg(mappingId);
|
||||
icon = QIcon(":/images/draw-triangle.png");
|
||||
icon = QIcon(":/shape-triangle");
|
||||
|
||||
if (paintType == "color")
|
||||
mapper = Mapper::ptr(new PolygonColorMapper(mapping));
|
||||
@@ -1374,7 +1526,7 @@ void MainWindow::addMappingItem(uid mappingId)
|
||||
else if (shapeType == "mesh" || shapeType == "quad")
|
||||
{
|
||||
label = QString(shapeType == "mesh" ? "Mesh %1" : "Quad %1").arg(mappingId);
|
||||
icon = QIcon(":/images/draw-rectangle-2.png");
|
||||
icon = QIcon(":/shape-mesh");
|
||||
if (paintType == "color")
|
||||
mapper = Mapper::ptr(new PolygonColorMapper(mapping));
|
||||
else
|
||||
@@ -1383,7 +1535,7 @@ void MainWindow::addMappingItem(uid mappingId)
|
||||
else if (shapeType == "ellipse")
|
||||
{
|
||||
label = QString("Ellipse %1").arg(mappingId);
|
||||
icon = QIcon(":/images/draw-ellipse-2.png");
|
||||
icon = QIcon(":/shape-ellipse");
|
||||
if (paintType == "color")
|
||||
mapper = Mapper::ptr(new EllipseColorMapper(mapping));
|
||||
else
|
||||
@@ -1392,7 +1544,7 @@ void MainWindow::addMappingItem(uid mappingId)
|
||||
else
|
||||
{
|
||||
label = QString("Polygon %1").arg(mappingId);
|
||||
icon = QIcon(":/images/draw-polygon-2.png");
|
||||
icon = QIcon(":/shape-polygon");
|
||||
}
|
||||
|
||||
// Add to list of mappers.
|
||||
@@ -1539,7 +1691,10 @@ void MainWindow::connectProjectWidgets()
|
||||
connect(mappingList, SIGNAL(itemActivated(QListWidgetItem*)),
|
||||
this, SLOT(handleItemSelected(QListWidgetItem*)));
|
||||
|
||||
connect(mappingList->model(), SIGNAL(layoutChanged()),
|
||||
connect(mappingList, SIGNAL(indexesMoved(const QModelIndexList&)),
|
||||
this, SLOT(handleMappingIndexesMoved()));
|
||||
|
||||
connect(mappingList->model(), SIGNAL(rowsMoved(const QModelIndex&, int, int, const QModelIndex &, int)),
|
||||
this, SLOT(handleMappingIndexesMoved()));
|
||||
}
|
||||
|
||||
@@ -1566,7 +1721,7 @@ void MainWindow::disconnectProjectWidgets()
|
||||
disconnect(mappingList, SIGNAL(itemActivated(QListWidgetItem*)),
|
||||
this, SLOT(handleItemSelected(QListWidgetItem*)));
|
||||
|
||||
disconnect(mappingList->model(), SIGNAL(layoutChanged()),
|
||||
disconnect(mappingList->model(), SIGNAL(rowsMoved(const QModelIndex&, int, int, const QModelIndex &, int)),
|
||||
this, SLOT(handleMappingIndexesMoved()));
|
||||
}
|
||||
|
||||
@@ -1688,8 +1843,13 @@ bool MainWindow::setTextureUri(int texture_id, const std::string &uri)
|
||||
{
|
||||
if (paint->getType() == "media")
|
||||
{
|
||||
Media *media = (Media *) paint.get(); // FIXME: use sharedptr cast
|
||||
success = media->setUri(QString(uri.c_str()));
|
||||
Media *media = (Media *) paint.get(); // FIXME: use sharedptr cast
|
||||
success = media->setUri(QString(uri.c_str()));
|
||||
}
|
||||
else if (paint->getType() == "image")
|
||||
{
|
||||
Image *media = (Image*) paint.get(); // FIXME: use sharedptr cast
|
||||
success = media->setUri(QString(uri.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -43,9 +43,6 @@
|
||||
#include "qttreepropertybrowser.h"
|
||||
#include "qtgroupboxpropertybrowser.h"
|
||||
|
||||
#define MAPMAP_VERSION "0.1.1"
|
||||
#define MAPMAP_EXTENSION "mmp"
|
||||
|
||||
/**
|
||||
* This is the main window of MapMap. It acts as both a view and a controller interface.
|
||||
*/
|
||||
@@ -79,7 +76,8 @@ private slots:
|
||||
void open();
|
||||
bool save();
|
||||
bool saveAs();
|
||||
void import();
|
||||
void importVideo();
|
||||
void importImage();
|
||||
void addColor();
|
||||
void about();
|
||||
void updateStatusBar();
|
||||
@@ -97,6 +95,10 @@ private slots:
|
||||
void addTriangle();
|
||||
void addEllipse();
|
||||
|
||||
void play();
|
||||
void pause();
|
||||
void rewind();
|
||||
|
||||
// Other.
|
||||
void windowModified();
|
||||
void pollOscInterface();
|
||||
@@ -108,8 +110,8 @@ public slots:
|
||||
/// Clears all mappings and paints.
|
||||
bool clearProject();
|
||||
|
||||
/// Create or replace an image paint.
|
||||
uid createMediaPaint(uid paintId, QString uri, float x, float y, Paint::ptr oldPaint);
|
||||
/// Create or replace a media paint (or image).
|
||||
uid createMediaPaint(uid paintId, QString uri, float x, float y, Paint::ptr oldPaint, bool isImage);
|
||||
|
||||
/// Create or replace a color paint.
|
||||
uid createColorPaint(uid paintId, QColor color, Paint::ptr oldPaint);
|
||||
@@ -182,7 +184,7 @@ public:
|
||||
bool loadFile(const QString &fileName);
|
||||
bool saveFile(const QString &fileName);
|
||||
void setCurrentFile(const QString &fileName);
|
||||
bool importMediaFile(const QString &fileName, Paint::ptr oldPaint);
|
||||
bool importMediaFile(const QString &fileName, Paint::ptr oldPaint, bool isImage);
|
||||
bool addColorPaint(const QColor& color, Paint::ptr oldPaint);
|
||||
void addMappingItem(uid mappingId);
|
||||
void removeMappingItem(uid mappingId);
|
||||
@@ -211,18 +213,21 @@ private:
|
||||
// QMenu *selectSubMenu;
|
||||
// QMenu *toolsMenu;
|
||||
// QMenu *optionsMenu;
|
||||
QMenu *viewMenu;
|
||||
QMenu *editMenu;
|
||||
QMenu *viewMenu;
|
||||
QMenu *runMenu;
|
||||
QMenu *helpMenu;
|
||||
|
||||
// Toolbar.
|
||||
QToolBar *fileToolBar;
|
||||
QToolBar *mainToolBar;
|
||||
QToolBar *runToolBar;
|
||||
|
||||
// Actions.
|
||||
QAction *separatorAction;
|
||||
QAction *newAction;
|
||||
QAction *openAction;
|
||||
QAction *importAction;
|
||||
QAction *importVideoAction;
|
||||
QAction *importImageAction;
|
||||
QAction *addColorAction;
|
||||
QAction *saveAction;
|
||||
QAction *saveAsAction;
|
||||
@@ -237,6 +242,10 @@ private:
|
||||
QAction *addTriangleAction;
|
||||
QAction *addEllipseAction;
|
||||
|
||||
QAction *playAction;
|
||||
QAction *pauseAction;
|
||||
QAction *rewindAction;
|
||||
|
||||
QAction *displayOutputWindow;
|
||||
QAction *outputWindowFullScreen;
|
||||
QAction *displayCanvasControls;
|
||||
@@ -280,13 +289,12 @@ private:
|
||||
uid currentMappingId;
|
||||
bool _hasCurrentMapping;
|
||||
bool _hasCurrentPaint;
|
||||
bool _isPlaying;
|
||||
|
||||
// Keeps track of the current selected item, wether it's a paint or mapping.
|
||||
QListWidgetItem* currentSelectedItem;
|
||||
QTimer *videoTimer;
|
||||
|
||||
static MainWindow* instance;
|
||||
|
||||
public:
|
||||
// Accessor/mutators for the view. ///////////////////////////////////////////////////////////////////
|
||||
MappingManager& getMappingManager() { return *mappingManager; }
|
||||
|
||||
@@ -223,7 +223,8 @@ void EllipseColorMapper::drawControls(QPainter* painter)
|
||||
|
||||
|
||||
TextureMapper::TextureMapper(std::tr1::shared_ptr<TextureMapping> mapping)
|
||||
: Mapper(mapping)
|
||||
: Mapper(mapping),
|
||||
_meshItem(NULL)
|
||||
{
|
||||
// Assign members pointers.
|
||||
textureMapping = std::tr1::static_pointer_cast<TextureMapping>(_mapping);
|
||||
|
||||
@@ -23,7 +23,13 @@
|
||||
#include "MainWindow.h"
|
||||
|
||||
MapperGLCanvas::MapperGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget * shareWidget)
|
||||
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget), _mainWindow(mainWindow), _mousepressed(false), _activeVertex(NO_VERTEX), _displayControls(true)
|
||||
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent, shareWidget),
|
||||
_mainWindow(mainWindow),
|
||||
_mousepressed(false),
|
||||
_activeVertex(NO_VERTEX),
|
||||
_shapeGrabbed(false), // comment out?
|
||||
_shapeFirstGrab(false), // comment out?
|
||||
_displayControls(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,14 +38,12 @@ void MapperGLCanvas::initializeGL()
|
||||
//qDebug() << "initializeGL" << endl;
|
||||
// Clear to black.
|
||||
qglClearColor(Qt::black);
|
||||
|
||||
// Antialiasing options.
|
||||
//QGLWidget::setFormat(QGLFormat(QGL::SampleBuffers));
|
||||
}
|
||||
|
||||
void MapperGLCanvas::resizeGL(int width, int height)
|
||||
{
|
||||
//qDebug() << "Resize to " << width << "x" << height << endl;
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
@@ -66,14 +70,19 @@ void MapperGLCanvas::draw(QPainter* painter)
|
||||
|
||||
void MapperGLCanvas::enterDraw(QPainter* painter)
|
||||
{
|
||||
painter->beginNativePainting();
|
||||
|
||||
// Clear to black.
|
||||
qglClearColor(Qt::black);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// Clear buffer.
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
painter->endNativePainting();
|
||||
|
||||
// Antialiasing.
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
//painter->setBackground(Qt::black);
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
}
|
||||
@@ -118,8 +127,8 @@ void MapperGLCanvas::mousePressEvent(QMouseEvent* event)
|
||||
Shape* shape = getCurrentShape();
|
||||
if (shape && shape->includesPoint(xmouse, ymouse))
|
||||
{
|
||||
_shapegrabbed = true;
|
||||
_shapefirstgrab = true;
|
||||
_shapeGrabbed = true;
|
||||
_shapeFirstGrab = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +138,7 @@ void MapperGLCanvas::mouseReleaseEvent(QMouseEvent* event)
|
||||
Q_UNUSED(event);
|
||||
// std::cout << "Mouse Release event " << std::endl;
|
||||
_mousepressed = false;
|
||||
_shapegrabbed = false;
|
||||
_shapeGrabbed = false;
|
||||
}
|
||||
|
||||
void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event)
|
||||
@@ -154,21 +163,21 @@ void MapperGLCanvas::mouseMoveEvent(QMouseEvent* event)
|
||||
emit shapeChanged(getCurrentShape());
|
||||
}
|
||||
}
|
||||
else if (_shapegrabbed)
|
||||
else if (_shapeGrabbed)
|
||||
{
|
||||
// std::cout << "Move event " << std::endl;
|
||||
Shape* shape = getCurrentShape();
|
||||
static QPointF prevMousePosition(0,0); // point that keeps track of last position of the mouse
|
||||
if (shape)
|
||||
{
|
||||
if (!_shapefirstgrab)
|
||||
if (!_shapeFirstGrab)
|
||||
{
|
||||
shape->translate(event->x() - prevMousePosition.x(), event->y() - prevMousePosition.y());
|
||||
update();
|
||||
emit shapeChanged(getCurrentShape());
|
||||
}
|
||||
else
|
||||
_shapefirstgrab = false;
|
||||
_shapeFirstGrab = false;
|
||||
}
|
||||
// Update previous mouse position.
|
||||
prevMousePosition.setX( event->x() );
|
||||
@@ -226,16 +235,12 @@ void MapperGLCanvas::paintEvent(QPaintEvent* /* event */)
|
||||
{
|
||||
makeCurrent();
|
||||
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
draw(&painter);
|
||||
|
||||
painter.end();
|
||||
// updateGL();
|
||||
}
|
||||
|
||||
void MapperGLCanvas::updateCanvas()
|
||||
@@ -276,7 +281,7 @@ void MapperGLCanvas::glueVertex(Shape *orig, QPointF *p)
|
||||
void MapperGLCanvas::deselectAll()
|
||||
{
|
||||
_activeVertex = NO_VERTEX;
|
||||
_shapegrabbed = false;
|
||||
_shapefirstgrab = false;
|
||||
_shapeGrabbed = false;
|
||||
_shapeFirstGrab = false;
|
||||
_mousepressed = false;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ private:
|
||||
MainWindow* _mainWindow;
|
||||
bool _mousepressed;
|
||||
int _activeVertex;
|
||||
bool _shapegrabbed;
|
||||
bool _shapefirstgrab;
|
||||
bool _shapeGrabbed;
|
||||
bool _shapeFirstGrab;
|
||||
bool _displayControls;
|
||||
|
||||
signals:
|
||||
|
||||
@@ -422,7 +422,7 @@ bool MediaImpl::loadMovie(QString filename)
|
||||
_bus = gst_element_get_bus (_pipeline);
|
||||
|
||||
// Start playing.
|
||||
if (!_setPlayState(true))
|
||||
if (!setPlayState(true))
|
||||
return false;
|
||||
|
||||
qDebug() << "Pipeline started.";
|
||||
@@ -431,7 +431,6 @@ bool MediaImpl::loadMovie(QString filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MediaImpl::runVideo() {
|
||||
|
||||
// if (!_VIDEO_OUT->connected())
|
||||
@@ -475,6 +474,25 @@ bool MediaImpl::runVideo() {
|
||||
return bitsChanged;
|
||||
}
|
||||
|
||||
bool MediaImpl::setPlayState(bool play)
|
||||
{
|
||||
if (_pipeline == NULL)
|
||||
return false;
|
||||
|
||||
GstStateChangeReturn ret = gst_element_set_state (_pipeline, (play ? GST_STATE_PLAYING : GST_STATE_PAUSED));
|
||||
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||
{
|
||||
qDebug() << "Unable to set the pipeline to the playing state.";
|
||||
unloadMovie();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_setReady(play);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//void VideoImpl::runAudio() {
|
||||
//
|
||||
@@ -618,27 +636,6 @@ void MediaImpl::_postRun()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MediaImpl::_setPlayState(bool play)
|
||||
{
|
||||
if (_pipeline == NULL)
|
||||
return false;
|
||||
|
||||
GstStateChangeReturn ret = gst_element_set_state (_pipeline, (play ? GST_STATE_PLAYING : GST_STATE_PAUSED));
|
||||
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||
{
|
||||
qDebug() << "Unable to set the pipeline to the playing state.";
|
||||
unloadMovie();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_setReady(play);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void MediaImpl::_setReady(bool ready)
|
||||
{
|
||||
_movieReady = ready;
|
||||
@@ -762,12 +759,12 @@ exit:
|
||||
void MediaImpl::internalPrePlay()
|
||||
{
|
||||
// Start/resume playback.
|
||||
_setPlayState(true);
|
||||
setPlayState(true);
|
||||
}
|
||||
|
||||
void MediaImpl::internalPostPlay()
|
||||
{
|
||||
// Pause playback.
|
||||
_setPlayState(false);
|
||||
setPlayState(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,10 +60,12 @@ public:
|
||||
// void runAudio();
|
||||
bool loadMovie(QString filename);
|
||||
|
||||
bool setPlayState(bool play);
|
||||
void resetMovie();
|
||||
|
||||
protected:
|
||||
void unloadMovie();
|
||||
void freeResources();
|
||||
void resetMovie();
|
||||
|
||||
void internalPrePlay();
|
||||
void internalPostPlay();
|
||||
@@ -76,7 +78,6 @@ private:
|
||||
|
||||
bool _preRun();
|
||||
void _postRun();
|
||||
bool _setPlayState(bool play);
|
||||
void _setReady(bool ready);
|
||||
void _setFinished(bool finished);
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@ Paint::~Paint()
|
||||
allocator.free(_id);
|
||||
}
|
||||
|
||||
bool Image::setUri(const QString &uri)
|
||||
{
|
||||
this->uri = uri;
|
||||
build();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Implementation of the Video class */
|
||||
|
||||
@@ -80,6 +86,21 @@ void Media::update() {
|
||||
bitsChanged = true;
|
||||
}
|
||||
|
||||
void Media::play()
|
||||
{
|
||||
impl_->setPlayState(true);
|
||||
}
|
||||
|
||||
void Media::pause()
|
||||
{
|
||||
impl_->setPlayState(false);
|
||||
}
|
||||
|
||||
void Media::rewind()
|
||||
{
|
||||
impl_->resetMovie();
|
||||
}
|
||||
|
||||
const uchar* Media::_getBits() const
|
||||
{
|
||||
return this->impl_->getBits();
|
||||
|
||||
@@ -67,6 +67,15 @@ public:
|
||||
/// This method should be called at each call of draw().
|
||||
virtual void update() {}
|
||||
|
||||
/// Starts playback.
|
||||
virtual void play() {}
|
||||
|
||||
/// Pauses playback.
|
||||
virtual void pause() {}
|
||||
|
||||
/// Rewinds.
|
||||
virtual void rewind() {}
|
||||
|
||||
void setName(const QString& name) { _name = name; }
|
||||
QString getName() const { return _name; }
|
||||
uid getId() const { return _id; }
|
||||
@@ -111,7 +120,11 @@ protected:
|
||||
x(0),
|
||||
y(0),
|
||||
bitsChanged(true)
|
||||
{}
|
||||
{
|
||||
glGenTextures(1, &textureId);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~Texture() {
|
||||
if (textureId != 0)
|
||||
glDeleteTextures(1, &textureId);
|
||||
@@ -119,10 +132,6 @@ protected:
|
||||
|
||||
public:
|
||||
GLuint getTextureId() const { return textureId; }
|
||||
virtual void loadTexture() {
|
||||
if (textureId == 0)
|
||||
glGenTextures(1, &textureId);
|
||||
}
|
||||
virtual int getWidth() const = 0;
|
||||
virtual int getHeight() const = 0;
|
||||
virtual const uchar* getBits() const {
|
||||
@@ -153,19 +162,21 @@ protected:
|
||||
|
||||
public:
|
||||
Image(const QString uri_, uid id=NULL_UID) :
|
||||
Texture(id),
|
||||
uri(uri_)
|
||||
Texture(id)
|
||||
{
|
||||
setUri(uri_);
|
||||
}
|
||||
|
||||
virtual ~Image() {}
|
||||
|
||||
const QString getUri() const { return uri; }
|
||||
|
||||
virtual void build() {
|
||||
image = QGLWidget::convertToGLFormat(QImage(uri));
|
||||
image = QGLWidget::convertToGLFormat(QImage(uri)).mirrored(true, false).transformed(QTransform().rotate(180));
|
||||
bitsChanged = true;
|
||||
}
|
||||
|
||||
const QString getUri() const { return uri; }
|
||||
bool setUri(const QString &uri);
|
||||
|
||||
virtual QString getType() const { return "image"; }
|
||||
|
||||
virtual int getWidth() const { return image.width(); }
|
||||
@@ -192,6 +203,14 @@ public:
|
||||
bool setUri(const QString &uri);
|
||||
virtual void build();
|
||||
virtual void update();
|
||||
|
||||
/// Starts playback.
|
||||
virtual void play();
|
||||
/// Pauses playback.
|
||||
virtual void pause();
|
||||
/// Rewinds.
|
||||
virtual void rewind();
|
||||
|
||||
virtual QString getType() const
|
||||
{
|
||||
return "media";
|
||||
|
||||
@@ -90,14 +90,14 @@ void ProjectReader::parsePaint(const QDomElement& paint)
|
||||
QString paintAttrName = paint.attribute("name", "");
|
||||
QString paintAttrType = paint.attribute("type", "");
|
||||
|
||||
if (paintAttrType == "media")
|
||||
if (paintAttrType == "media" || paintAttrType == "image")
|
||||
{
|
||||
QString uri = paint.firstChildElement("uri").text();
|
||||
QString x = paint.firstChildElement("x").text();
|
||||
QString y = paint.firstChildElement("y").text();
|
||||
|
||||
uid id = _window->createMediaPaint(paintAttrId.toInt(), uri, x.toFloat(), y.toFloat(),
|
||||
std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)));
|
||||
std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), paintAttrType == "image");
|
||||
if (id == NULL_UID)
|
||||
_xml.raiseError(QObject::tr("Cannot create media with uri %1.").arg(uri));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void ProjectWriter::writeItem(Paint *item)
|
||||
|
||||
if (item->getType() == "media")
|
||||
{
|
||||
// FIXME: check paint type before casting to Image
|
||||
// FIXME: check paint type before casting to Media
|
||||
Media *media = (Media *) item;
|
||||
|
||||
_xml.writeTextElement("uri", media->getUri());
|
||||
@@ -78,6 +78,27 @@ void ProjectWriter::writeItem(Paint *item)
|
||||
_xml.writeEndElement();
|
||||
//_xml.writeEmptyElement("hello");
|
||||
}
|
||||
else if (item->getType() == "image")
|
||||
{
|
||||
// FIXME: check paint type before casting to Image
|
||||
Image *media = (Image *) item;
|
||||
|
||||
_xml.writeTextElement("uri", media->getUri());
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << media->getX();
|
||||
_xml.writeTextElement("x", os.str().c_str());
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << media->getY();
|
||||
_xml.writeTextElement("y", os.str().c_str());
|
||||
}
|
||||
|
||||
_xml.writeEndElement();
|
||||
//_xml.writeEmptyElement("hello");
|
||||
}
|
||||
else if (item->getType() == "color")
|
||||
{
|
||||
// FIXME: check paint type before casting to Image
|
||||
|
||||
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -59,10 +59,8 @@ int main(int argc, char *argv[])
|
||||
// set_language_to_french(app);
|
||||
if (FORCE_FRENCH_LANG)
|
||||
{
|
||||
// Set translator.
|
||||
QTranslator translator;
|
||||
translator.load("mapmap_fr");
|
||||
app.installTranslator(&translator);
|
||||
std::cerr << "This system has no OpenGL support" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Let splash for at least one second.
|
||||
@@ -70,22 +68,27 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Create window.
|
||||
MainWindow win;
|
||||
|
||||
QFontDatabase db;
|
||||
Q_ASSERT( QFontDatabase::addApplicationFont(":/base-font") != -1);
|
||||
app.setFont(QFont(":/base-font", 10, QFont::Bold));
|
||||
|
||||
// Load stylesheet.
|
||||
QFile stylesheet("mapmap.qss");
|
||||
stylesheet.open(QFile::ReadOnly);
|
||||
app.setStyleSheet(QLatin1String(stylesheet.readAll()));
|
||||
|
||||
//win.setLocale(QLocale("fr"));
|
||||
|
||||
// Load file from commandline (optional).
|
||||
if (QCoreApplication::arguments().size() > 1)
|
||||
win.loadFile(QCoreApplication::arguments().at(1));
|
||||
|
||||
// Show window.
|
||||
win.show();
|
||||
|
||||
// Terminate splash.
|
||||
splash.showMessage(" " + QObject::tr("Done."),
|
||||
Qt::AlignLeft | Qt::AlignTop, MM::WHITE);
|
||||
I::msleep(500);
|
||||
splash.finish(&win);
|
||||
splash.raise();
|
||||
|
||||
// Launch program.
|
||||
win.show();
|
||||
|
||||
// Start app.
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
TEMPLATE = app
|
||||
TARGET = mapmap
|
||||
QT += gui opengl xml
|
||||
CONFIG += qt debug
|
||||
DEFINES += UNICODE QT_THREAD_SUPPORT QT_CORE_LIB QT_GUI_LIB
|
||||
|
||||
HEADERS = \
|
||||
DestinationGLCanvas.h \
|
||||
MainApplication.h \
|
||||
MainWindow.h \
|
||||
Mapper.h \
|
||||
MapperGLCanvas.h \
|
||||
Mapping.h \
|
||||
MappingManager.h \
|
||||
Maths.h \
|
||||
OscInterface.h \
|
||||
OscReceiver.h \
|
||||
OutputGLWindow.h \
|
||||
Paint.h \
|
||||
ProjectReader.h \
|
||||
ProjectWriter.h \
|
||||
Shape.h \
|
||||
SourceGLCanvas.h \
|
||||
UidAllocator.h \
|
||||
Util.h \
|
||||
unused.h \
|
||||
VideoImpl.h
|
||||
|
||||
SOURCES = \
|
||||
DestinationGLCanvas.cpp \
|
||||
MainWindow.cpp \
|
||||
MainApplication.cpp \
|
||||
Mapper.cpp \
|
||||
MapperGLCanvas.cpp \
|
||||
Mapping.cpp \
|
||||
MappingManager.cpp \
|
||||
OscInterface.cpp \
|
||||
OscReceiver.cpp \
|
||||
OutputGLWindow.cpp \
|
||||
ProjectReader.h \
|
||||
Paint.cpp \
|
||||
ProjectReader.cpp \
|
||||
ProjectWriter.cpp \
|
||||
Shape.cpp \
|
||||
SourceGLCanvas.cpp \
|
||||
UidAllocator.cpp \
|
||||
Util.cpp \
|
||||
VideoImpl.cpp \
|
||||
main.cpp
|
||||
|
||||
QT += gui opengl xml
|
||||
RESOURCES = mapmap.qrc
|
||||
TRANSLATIONS = mapmap_fr.ts
|
||||
include(contrib/qtpropertybrowser/src/qtpropertybrowser.pri)
|
||||
docs.depends = $(HEADERS) $(SOURCES)
|
||||
docs.commands = (cat Doxyfile; echo "INPUT = $?") | doxygen -
|
||||
QMAKE_EXTRA_TARGETS += docs
|
||||
|
||||
# Linux-specific:
|
||||
unix:!mac {
|
||||
DEFINES += UNIX
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += gstreamer-0.10 gstreamer-base-0.10 glib-2.0 libxml-2.0
|
||||
|
||||
# stricter build flags:
|
||||
QMAKE_CXXFLAGS += -Wno-unused-result -Wfatal-errors
|
||||
QMAKE_CXXFLAGS += -DHAVE_OSC
|
||||
|
||||
QMAKE_LFLAGS_RPATH+=-Wl,-rpath=/opt/gstreamer-sdk/lib
|
||||
#INCLUDEPATH += \
|
||||
# /usr/include/gstreamer-0.10 \
|
||||
# /usr/local/include/gstreamer-0.10 \
|
||||
# /usr/include/glib-2.0 \
|
||||
# /usr/lib/x86_64-linux-gnu/glib-2.0/include \
|
||||
# /usr/include/libxml2
|
||||
LIBS += \
|
||||
# -lgstreamer-0.10 \
|
||||
# -lgstinterfaces-0.10 \
|
||||
# -lglib-2.0 \
|
||||
-lglut \
|
||||
-llo -lpthread \
|
||||
# -lgmodule-2.0 \
|
||||
# -lgobject-2.0 \
|
||||
-lgthread-2.0 \
|
||||
-lGLU \
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
-llo \
|
||||
-lpthread
|
||||
LIBS += -lgstreamer-0.10 \
|
||||
-lgstinterfaces-0.10 \
|
||||
-lglib-2.0 \
|
||||
-lglut \
|
||||
-llo -lpthread \
|
||||
-lgmodule-2.0 \
|
||||
-lgobject-2.0 \
|
||||
-lgthread-2.0 \
|
||||
-lGLU \
|
||||
>>>>>>> gst-osx
|
||||
-lGL \
|
||||
-lX11 \
|
||||
-lGLEW
|
||||
}
|
||||
|
||||
# Mac OS X-specific:
|
||||
mac {
|
||||
DEFINES += MACOSX
|
||||
INCLUDEPATH += \
|
||||
/opt/local/include/ \
|
||||
/opt/local/include/libxml2
|
||||
LIBS += \
|
||||
-framework OpenGL \
|
||||
-framework GLUT
|
||||
QMAKE_CXXFLAGS += -D__MACOSX_CORE__
|
||||
QMAKE_CXXFLAGS += -stdlib=libstdc++
|
||||
|
||||
INCLUDEPATH += /Library/Frameworks/GStreamer.framework/Headers
|
||||
# LIBS+=-lavformat -lavcodec -lavutil -lswscale -lz
|
||||
LIBS += -F /Library/Frameworks/ -framework GStreamer
|
||||
# QMAKE_LFLAGS+=-read_only_relocs suppress
|
||||
|
||||
# LIBS += -lgstreamer-0.10 \
|
||||
# -lgstapp-0.10 \
|
||||
# -lgstvideo-0.10 \
|
||||
# -lglib-2.0 \
|
||||
# -lgobject-2.0
|
||||
LIBS += -framework OpenGL -framework GLUT
|
||||
QMAKE_CXXFLAGS += -D__MACOSX_CORE__
|
||||
}
|
||||
|
||||
# Windows-specific:
|
||||
win32 {
|
||||
DEFINES += WIN32
|
||||
INCLUDEPATH += \
|
||||
C:/gstreamer/include \
|
||||
C:/gstreamer/include/libxml2 \
|
||||
C:/gstreamer/include/glib-2.0 \
|
||||
C:/gstreamer/lib/glib-2.0/include \
|
||||
C:/gstreamer/include/gstreamer-0.10
|
||||
LIBS += -L"C:/gstreamer/lib" \
|
||||
-L"C:/gstreamer/bin" \
|
||||
-lgstreamer-0.10 \
|
||||
-lglib-2.0 \
|
||||
-lgmodule-2.0 \
|
||||
-lgobject-2.0 \
|
||||
-lgthread-2.0 \
|
||||
-lgstinterfaces-0.10 \
|
||||
-lopengl32 \
|
||||
-lglu32 \
|
||||
-lglew32
|
||||
# Add console to the CONFIG to see debug messages printed in
|
||||
# the console on Windows
|
||||
CONFIG += console
|
||||
}
|
||||
|
||||
@@ -1,14 +1,43 @@
|
||||
<RCC>
|
||||
<qresource>
|
||||
<file>images/document-new-4.png</file>
|
||||
<file>images/document-open-3.png</file>
|
||||
<file>images/document-save-2.png</file>
|
||||
<file>images/document-save-as-2.png</file>
|
||||
<file>images/document-import-2.png</file>
|
||||
<file>images/draw-rectangle-2.png</file>
|
||||
<file>images/draw-triangle.png</file>
|
||||
<file>images/draw-ellipse-2.png</file>
|
||||
<file>images/colorize.png</file>
|
||||
<file alias="new">resources/images/icons/newdoc_w.png</file>
|
||||
<file alias="open">resources/images/icons/open_w.png</file>
|
||||
<file alias="save">resources/images/icons/save_w.png</file>
|
||||
<file alias="save-as">resources/images/icons/save_w.png</file>
|
||||
|
||||
<file alias="fullscreen">resources/images/icons/fullscreen_w.png</file>
|
||||
<file alias="output-window">resources/images/icons/nofullscreen_w.png</file>
|
||||
<file alias="control-points">resources/images/icons/ctrl2_w.png</file>
|
||||
|
||||
<file alias="add-video">resources/images/icons/add_movie_w.png</file>
|
||||
<file alias="add-image">resources/images/icons/add_img_w.png</file>
|
||||
<file alias="add-color">resources/images/icons/add_paint_w.png</file>
|
||||
|
||||
<file alias="add-mesh">resources/images/shapes/add_quad.png</file>
|
||||
<file alias="add-triangle">resources/images/shapes/add_triangle.png</file>
|
||||
<file alias="add-ellipse">resources/images/shapes/add_circle.png</file>
|
||||
|
||||
<!--
|
||||
<file alias="add-mesh">resources/images/icons/ad_quad_w.png</file>
|
||||
<file alias="add-triangle">resources/images/icons/ad_tri_w.png</file>
|
||||
<file alias="add-ellipse">resources/images/icons/ad_cerl_w.png</file>
|
||||
|
||||
<file alias="add-mesh">resources/images/icons/ad_quad.png</file>
|
||||
<file alias="add-triangle">resources/images/icons/ad_tri_.png</file>
|
||||
<file alias="add-ellipse">resources/images/icons/ad_cer.png</file>
|
||||
-->
|
||||
|
||||
<file alias="play">resources/images/icons/play_w.png</file>
|
||||
<file alias="pause">resources/images/icons/pause_w.png</file>
|
||||
<file alias="rewind">resources/images/icons/rewind_w.png</file>
|
||||
|
||||
<file alias="shape-mesh">resources/images/shapes/add_quad.png</file>
|
||||
<file alias="shape-triangle">resources/images/shapes/add_triangle.png</file>
|
||||
<file alias="shape-ellipse">resources/images/shapes/add_circle.png</file>
|
||||
|
||||
<file alias="shape-polygon">resources/images/shapes/add_circle.png</file>
|
||||
|
||||
<file alias="base-font">resources/fonts/HelveticaNeueLTPro-Bd.otf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Colors:
|
||||
White: #f6f5f5
|
||||
Dark gray: #323541 (darker: #00020E lighter: #4C4F5B)
|
||||
Darker gray: #272a36
|
||||
*/
|
||||
|
||||
QMainWindow
|
||||
{
|
||||
/* background-color: #f6f5f5;*/
|
||||
background-color: #272a36;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/*QToolButton {
|
||||
color: #f6f5f5;
|
||||
}
|
||||
*/
|
||||
|
||||
QToolButton::hover, QToolButton::checked {
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,
|
||||
stop: 0 #0c0927, stop: 1 #00020E);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
QToolButton::checked:hover {
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,
|
||||
stop: 0 #0c0927, stop: 1 #191C28);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
QToolBar::separator:horizontal {
|
||||
/* background-color: #272a36;
|
||||
width: 3px;
|
||||
color: #f6f5f5;
|
||||
/* image: url(:/separator); */
|
||||
width: 64;
|
||||
}
|
||||
|
||||
QListView {
|
||||
background-color: #323541;
|
||||
border: 1px solid #323541;
|
||||
}
|
||||
|
||||
QListView::item {
|
||||
color: #f6f5f5;
|
||||
}
|
||||
|
||||
QListView::item:alternate {
|
||||
background: #EEEEEE;
|
||||
}
|
||||
|
||||
QListView::item:selected {
|
||||
background: #272a36;
|
||||
}
|
||||
|
||||
/*
|
||||
QListView::item:selected:!active {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #ABAFE5, stop: 1 #8588B2);
|
||||
}
|
||||
|
||||
QListView::item:selected:active {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #6a6ea9, stop: 1 #888dd9);
|
||||
}
|
||||
|
||||
QListView::item:hover {
|
||||
stop: 0 #FAFBFE, stop: 1 #DCDEF1);
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
}*/
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 998 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 916 B |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 912 B |
|
After Width: | Height: | Size: 937 B |
|
After Width: | Height: | Size: 915 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 962 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 969 B |
|
After Width: | Height: | Size: 936 B |
|
After Width: | Height: | Size: 907 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.8 KiB |