Merge branch 'develop' of https://github.com/mapmapteam/mapmap into develop

This commit is contained in:
baydam
2016-01-05 12:19:38 +00:00
11 changed files with 187 additions and 277 deletions
+45 -10
View File
@@ -1,12 +1,19 @@
# Eclipse
.cproject
.project
.settings
Debug/
Release/
# Generated
*.la
*.lo
*.o
*.pc
.deps
.libs
# Big files
.*.swp
*.zip
*.gz
@@ -18,22 +25,33 @@
*.tar
*.rar
*.qm
*.psd
*.ai
*.gif
*.svg
*.ps
*.pdf
# Other files
*.out
*.log
callgrind.out.*
*.dot
# Makefiles
Makefile*
prototypes/sdl/run
prototypes/wx-01-simple/run
prototypes/wx-03-polyline/run
prototypes/wx-04-gst/run
Debug/
Release/
# Generated by Qt
mapmap
moc_*.cpp
prototypes/gst/
prototypes/wx-02-input-output/run
qrc_*.cpp
qteditorfactory.moc
qtpropertymanager.moc
qttreepropertybrowser.moc
*.moc
# Folders not to be included
html/
# Mac
.DS_Store
.qmake.stash
Info.plist
@@ -42,3 +60,20 @@ Info.plist
*.app
DMGVERSION.txt
*.db
# Created by git.
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
# Local stuff
prototypes/sdl/run
prototypes/wx-01-simple/run
prototypes/wx-03-polyline/run
prototypes/wx-04-gst/run
prototypes/wx-02-input-output/run
prototypes/qgraphicsview
contrib/qtpropertybrowser.new
contrib/pblazasm-read-only
trash
-215
View File
@@ -1,215 +0,0 @@
/*
* DestinationGLCanvas.cpp
*
* (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
* (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "DestinationGLCanvas.h"
#include "MainWindow.h"
<<<<<<< HEAD
DestinationGLCanvas::DestinationGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget * shareWidget)
: MapperGLCanvas(mainWindow, parent, shareWidget),
_displayCrosshair(false),
_svg_test_signal(":/test-signal"),
_brush_test_signal(_svg_test_signal)
=======
DestinationGLCanvas::DestinationGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget* shareWidget, QGraphicsScene* scene)
: MapperGLCanvas(mainWindow, parent, shareWidget, scene),
_displayCrosshair(false)
>>>>>>> spike-qgraphicsview-zoom-and-scroll
{
}
MShape* DestinationGLCanvas::getShapeFromMappingId(uid mappingId)
{
if (mappingId == NULL_UID)
return NULL;
else
return getMainWindow()->getMappingManager().getMappingById(mappingId)->getShape().get();
}
<<<<<<< HEAD
void DestinationGLCanvas::doDraw(QPainter* painter)
{
if (this->displayTestSignal())
{
glPushMatrix();
painter->save();
this->_drawTestSignal(painter);
painter->restore();
glPopMatrix();
return;
}
glPushMatrix();
// Draw the mappings.
QVector<Mapping::ptr> mappings = getMainWindow()->getMappingManager().getVisibleMappings();
for (QVector<Mapping::ptr>::const_iterator it = mappings.begin(); it != mappings.end(); ++it)
{
painter->save();
getMainWindow()->getMapperByMappingId((*it)->getId())->draw(painter);
painter->restore();
}
// Draw the controls of current mapping.
if (displayControls() &&
getMainWindow()->hasCurrentMapping() &&
getCurrentShape() != NULL)
{
painter->save();
const Mapper::ptr& mapper = getMainWindow()->getMapperByMappingId(getMainWindow()->getCurrentMappingId());
if (hasActiveVertex()) {
QList<int> selectedVertices;
selectedVertices.append(getActiveVertexIndex());
mapper->drawControls(painter, &selectedVertices);
}
else
{
mapper->drawControls(painter);
}
painter->restore();
}
glPopMatrix();
// Display crosshair cursor.
=======
void DestinationGLCanvas::drawForeground(QPainter *painter , const QRectF &rect) {
>>>>>>> spike-qgraphicsview-zoom-and-scroll
if (_displayCrosshair)
{
QPointF cursorPosition = mapToScene(cursor().pos());// - rect.topLeft();//(QCursor::pos());///*this->mapFromGlobal(*/QCursor::pos()/*)*/;
if (rect.contains(cursorPosition))
{
painter->setPen(MM::CONTROL_COLOR);
painter->drawLine(cursorPosition.x(), rect.y(), cursorPosition.x(), rect.height());
painter->drawLine(rect.x(), cursorPosition.y(), rect.width(), cursorPosition.y());
}
}
}
<<<<<<< HEAD
void DestinationGLCanvas::_drawTestSignal(QPainter* painter)
{
const QRect& geo = geometry();
painter->setPen(MM::CONTROL_COLOR);
int height = geo.height();
int width = geo.width();
int rect_size = 10;
QColor color_0(191, 191, 191);
QColor color_1(128, 128, 128);
QBrush brush_0(color_0);
QBrush brush_1(color_1);
painter->setPen(Qt::NoPen);
for (int x = 0; x < width; x += rect_size)
{
for (int y = 0; y < height; y += rect_size)
{
if (((x + y) % 20) == 0)
{
painter->setBrush(brush_0);
} else {
painter->setBrush(brush_1);
}
painter->drawRect(x, y, rect_size, rect_size);
}
}
painter->fillRect(geo, this->_brush_test_signal);
}
void DestinationGLCanvas::resizeGL(int width, int height)
{
int side_length = width;
if (height < width)
{
side_length = height;
}
(void) side_length; // to get rid of warnings
// TODO: reload SVG with the new size
// TODO: _svg_test_signal.load(":/test-signal");
// TODO: _brush_test_signal(_svg_test_signal)
}
bool DestinationGLCanvas::eventFilter(QObject *target, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
setActiveVertexIndex(getMainWindow()->getOutputWindow()->getCanvas()->getActiveVertexIndex());
MapperGLCanvas::keyPressEvent(keyEvent);
return true;
}
else
{
return QObject::eventFilter(target, event);
}
}
=======
//void DestinationGLCanvas::doDraw(QPainter* painter)
//{
// glPushMatrix();
//
// // Draw the mappings.
// QVector<Mapping::ptr> mappings = getMainWindow()->getMappingManager().getVisibleMappings();
// for (QVector<Mapping::ptr>::const_iterator it = mappings.begin(); it != mappings.end(); ++it)
// {
// painter->save();
// getMainWindow()->getMapperByMappingId((*it)->getId())->draw(painter);
// painter->restore();
// }
//
// // Draw the controls of current mapping.
// if (displayControls() &&
// getMainWindow()->hasCurrentMapping() &&
// getCurrentShape() != NULL)
// {
// painter->save();
// const Mapper::ptr& mapper = getMainWindow()->getMapperByMappingId(getMainWindow()->getCurrentMappingId());
// if (hasActiveVertex()) {
// QList<int> selectedVertices;
// selectedVertices.append(getActiveVertexIndex());
// mapper->drawControls(painter, &selectedVertices);
// }
// else
// mapper->drawControls(painter);
// painter->restore();
// }
//
// glPopMatrix();
//
// // Display crosshair cursor.
// if (_displayCrosshair)
// {
// const QPoint& cursorPosition = this->mapFromGlobal(QCursor::pos());
// const QRect& geo = geometry();
// if (geo.contains(cursorPosition))
// {
// painter->setPen(MM::CONTROL_COLOR);
// painter->drawLine(cursorPosition.x(), 0, cursorPosition.x(), geo.height());
// painter->drawLine(0, cursorPosition.y(), geo.width(), cursorPosition.y());
// }
// }
//
//}
>>>>>>> spike-qgraphicsview-zoom-and-scroll
+2 -2
View File
@@ -1693,7 +1693,7 @@ void MainWindow::createMenus()
void MainWindow::createMappingContextMenu()
{
// Context menu.
mappingContextMenu = new QMenu();
mappingContextMenu = new QMenu(this);
// Add different Action
mappingContextMenu->addAction(cloneAction);
@@ -1714,7 +1714,7 @@ void MainWindow::createMappingContextMenu()
void MainWindow::createPaintContextMenu()
{
// Paint Context Menu
paintContextMenu = new QMenu();
paintContextMenu = new QMenu(this);
// Add Actions
paintContextMenu->addAction(deletePaintAction);
+1 -1
View File
@@ -87,7 +87,7 @@ void MapperGLCanvas::drawForeground(QPainter *painter , const QRectF &rect)
QList<int> selected;
if (hasActiveVertex())
selected.push_back(getActiveVertexIndex());
item->getControlPainter()->paint(painter, selected);
item->getControlPainter()->paint(painter, this, selected);
}
}
}
+101 -12
View File
@@ -44,14 +44,16 @@ bool MediaImpl::hasVideoSupport()
int MediaImpl::getWidth() const
{
Q_ASSERT(videoIsConnected());
return _padHandlerData.width;
return _width;
// Q_ASSERT(videoIsConnected());
// return _padHandlerData.width;
}
int MediaImpl::getHeight() const
{
Q_ASSERT(videoIsConnected());
return _padHandlerData.height;
return _height;
// Q_ASSERT(videoIsConnected());
// return _padHandlerData.height;
}
const uchar* MediaImpl::getBits()
@@ -174,14 +176,14 @@ GstFlowReturn MediaImpl::gstNewSampleCallback(GstElement*, MediaImpl *p)
// For live sources, video dimensions have not been set, because
// gstPadAddedCallback is never called. Fix dimensions from first sample /
// caps we receive.
if (p->_isSharedMemorySource && ( p->_padHandlerData.width == -1 ||
p->_padHandlerData.height == -1)) {
if (p->_isSharedMemorySource &&
( p->_width == -1 ||
p->_height == -1)) {
GstCaps *caps = gst_sample_get_caps(sample);
GstStructure *structure;
structure = gst_caps_get_structure(caps, 0);
gst_structure_get_int(structure, "width", &p->_padHandlerData.width);
gst_structure_get_int(structure, "height", &p->_padHandlerData.height);
// g_print("Size is %u x %u\n", _padHandlerData.width, _padHandlerData.height);
gst_structure_get_int(structure, "width", &p->_width);
gst_structure_get_int(structure, "height", &p->_height);
}
// Try to retrieve data bits of frame.
@@ -221,8 +223,10 @@ _audiosink0(NULL),
_currentFrameSample(NULL),
_currentFrameBuffer(NULL),
_bitsChanged(false),
_width(640), // unused
_height(480), // unused
_width(-1),
_height(-1),
_duration(0),
//_isSeekable(false),
_data(NULL),
_seekEnabled(false),
_rate(1.0),
@@ -250,6 +254,11 @@ void MediaImpl::unloadMovie()
_setMovieReady(false);
setPlayState(false);
// Reinit.
_width = _height = -1;
_duration = 0;
// _isSeekable = false;
// Free allocated resources.
freeResources();
}
@@ -345,7 +354,8 @@ gstPollShmsrc (void *user_data)
bool MediaImpl::loadMovie(QString filename)
{
gchar* filetestpath = (gchar*) filename.toUtf8().constData();
// Verify if file exists.
const gchar* filetestpath = (const gchar*) filename.toUtf8().constData();
if (FALSE == g_file_test(filetestpath, G_FILE_TEST_EXISTS))
{
std::cout << "File " << filetestpath << " does not exist" << std::endl;
@@ -512,7 +522,86 @@ bool MediaImpl::loadMovie(QString filename)
// Connect to the pad-added signal
if (! _isSharedMemorySource)
{
// Extract meta info.
GError* error = NULL;
GstDiscoverer* discoverer = gst_discoverer_new(5*GST_SECOND, &error);
if (!discoverer)
{
std::cout << "Error creating discoverer: " << error->message << std::endl;
g_clear_error (&error);
return false;
}
GstDiscovererInfo* info = gst_discoverer_discover_uri(discoverer, uri, &error);
if (!info)
{
std::cout << "Error getting discoverer info: " << error->message << std::endl;
g_clear_error (&error);
return false;
}
GstDiscovererResult result = gst_discoverer_info_get_result(info);
switch (result) {
case GST_DISCOVERER_URI_INVALID:
std::cout<< "Invalid URI '" << uri << "'" << std::endl;
break;
case GST_DISCOVERER_ERROR:
std::cout<< "Discoverer error: " << error->message << std::endl;
break;
case GST_DISCOVERER_TIMEOUT:
std::cout << "Timeout" << std::endl;
break;
case GST_DISCOVERER_BUSY:
std::cout << "Busy" << std::endl;
break;
case GST_DISCOVERER_MISSING_PLUGINS:{
const GstStructure *s;
gchar *str;
s = gst_discoverer_info_get_misc (info);
str = gst_structure_to_string (s);
std::cout << "Missing plugins: " << str << std::endl;
g_free (str);
break;
}
case GST_DISCOVERER_OK:
std::cout << "Discovered '" << uri << "'" << std::endl;
break;
}
g_clear_error (&error);
if (result != GST_DISCOVERER_OK) {
std::cout << "This URI cannot be played" << std::endl;
return false;
}
// Gather info from video.
GList *videoStreams = gst_discoverer_info_get_video_streams (info);
if (!videoStreams)
{
std::cout << "This URI does not contain any video streams" << std::endl;
return false;
}
// Retrieve meta-info.
_width = gst_discoverer_video_info_get_width((GstDiscovererVideoInfo*)videoStreams->data);
_height = gst_discoverer_video_info_get_height((GstDiscovererVideoInfo*)videoStreams->data);
// _isSeekable = gst_discoverer_info_get_seekable(info);
_duration = gst_discoverer_info_get_duration(info);
// Free everything.
g_object_unref(discoverer);
gst_discoverer_info_unref(info);
gst_discoverer_stream_info_list_free(videoStreams);
// Connect pad signal.
g_signal_connect (_uridecodebin0, "pad-added", G_CALLBACK (MediaImpl::gstPadAddedCallback), &_padHandlerData);
// Set uri of decoder.
g_object_set (_uridecodebin0, "uri", uri, NULL);
}
else
+10 -6
View File
@@ -28,6 +28,7 @@
// GStreamer includes.
#include <gst/gst.h>
#include <gst/app/gstappsink.h>
#include <gst/pbutils/pbutils.h>
// Other includes.
#include <QtGlobal>
@@ -125,6 +126,7 @@ public:
bool loadMovie(QString filename);
bool setPlayState(bool play);
bool getPlayState() const { return _playState; }
/**
* Tells the MediaImpl that we are actually reading from a shmsrc.
@@ -159,7 +161,6 @@ private:
void _checkMessages();
void _setMovieReady(bool ready);
bool _isMovieReady() const { return _movieReady; }
bool getPlayState() const { return _playState; }
void _setFinished(bool finished);
// Sends the appropriate seek events to adjust to rate.
@@ -226,6 +227,14 @@ private:
GstMapInfo _mapInfo;
bool _bitsChanged;
/**
* Contains meta informations about current file.
*/
int _width;
int _height;
// bool _isSeekable;
unsigned long _duration; // duration (in nanoseconds) (unused for now)
/**
* shmsrc socket poller.
*/
@@ -233,11 +242,6 @@ private:
GstPadHandlerData _padHandlerData;
// unused
int _width;
// unused
int _height;
/// Raw image data of the last video frame.
uchar *_data;
+17 -12
View File
@@ -27,15 +27,15 @@ ShapeControlPainter::ShapeControlPainter(ShapeGraphicsItem* shapeItem)
MShape::ptr ShapeControlPainter::getShape() const { return _shapeItem->getShape(); }
void ShapeControlPainter::paint(QPainter *painter, const QList<int>& selectedVertices)
void ShapeControlPainter::paint(QPainter *painter, MapperGLCanvas* canvas, const QList<int>& selectedVertices)
{
_paintShape(painter);
_paintVertices(painter, selectedVertices);
_paintShape(painter, canvas);
_paintVertices(painter, canvas, selectedVertices);
}
void ShapeControlPainter::_paintVertices(QPainter *painter, const QList<int>& selectedVertices)
void ShapeControlPainter::_paintVertices(QPainter *painter, MapperGLCanvas* canvas, const QList<int>& selectedVertices)
{
qreal zoomFactor = _shapeItem->getCanvas()->getZoomFactor();
qreal zoomFactor = canvas->getZoomFactor();
qreal selectRadius = MM::VERTEX_SELECT_RADIUS / zoomFactor;
qreal strokeWidth = MM::VERTEX_SELECT_STROKE_WIDTH / zoomFactor;
@@ -43,26 +43,31 @@ void ShapeControlPainter::_paintVertices(QPainter *painter, const QList<int>& se
Util::drawControlsVertex(painter, getShape()->getVertex(i), selectedVertices.contains(i), selectRadius, strokeWidth);
}
void PolygonControlPainter::_paintShape(QPainter *painter)
QPen ShapeControlPainter::getRescaledShapeStroke(MapperGLCanvas* canvas, bool innerStroke)
{
return QPen(QBrush(MM::CONTROL_COLOR), (innerStroke ? MM::SHAPE_INNER_STROKE_WIDTH : MM::SHAPE_STROKE_WIDTH) / canvas->getZoomFactor());
}
void PolygonControlPainter::_paintShape(QPainter *painter, MapperGLCanvas* canvas)
{
Polygon* poly = static_cast<Polygon*>(getShape().data());
Q_ASSERT(poly);
// Init colors and stroke.
painter->setPen(_shapeItem->getRescaledShapeStroke());
painter->setPen(getRescaledShapeStroke(canvas));
// Draw inner quads.
painter->drawPolygon(poly->toPolygon());
}
void EllipseControlPainter::_paintShape(QPainter *painter)
void EllipseControlPainter::_paintShape(QPainter *painter, MapperGLCanvas* canvas)
{
Ellipse* ellipse = static_cast<Ellipse*>(getShape().data());
Q_ASSERT(ellipse);
// Init colors and stroke.
painter->setPen(_shapeItem->getRescaledShapeStroke());
painter->setPen(getRescaledShapeStroke(canvas));
painter->setBrush(Qt::NoBrush);
// Draw ellipse contour.
@@ -74,13 +79,13 @@ void EllipseControlPainter::_paintShape(QPainter *painter)
painter->drawPath(transform.map(path));
}
void MeshControlPainter::_paintShape(QPainter *painter)
void MeshControlPainter::_paintShape(QPainter *painter, MapperGLCanvas* canvas)
{
Mesh* mesh = static_cast<Mesh*>(getShape().data());
Q_ASSERT(mesh);
// Init colors and stroke.
painter->setPen(_shapeItem->getRescaledShapeStroke(true));
painter->setPen(getRescaledShapeStroke(canvas, true));
// Draw inner quads.
QVector<Quad> quads = mesh->getQuads();
@@ -90,7 +95,7 @@ void MeshControlPainter::_paintShape(QPainter *painter)
}
// Draw outer quad.
painter->setPen(_shapeItem->getRescaledShapeStroke());
painter->setPen(getRescaledShapeStroke(canvas));
painter->drawPolygon(_shapeItem->mapFromScene(mesh->toPolygon()));
}
+10 -6
View File
@@ -24,9 +24,11 @@
#include <QtGlobal>
#include "MM.h"
#include "MapperGLCanvas.h"
#include "ShapeGraphicsItem.h"
class ShapeGraphicsItem;
class MapperGLCanvas;
/**
* An object responsible to paint control points for a specific ShapeGraphicsItem.
@@ -41,11 +43,13 @@ public:
MShape::ptr getShape() const;
virtual void paint(QPainter *painter, const QList<int>& selectedVertices = QList<int>());
virtual void paint(QPainter *painter, MapperGLCanvas* canvas, const QList<int>& selectedVertices = QList<int>());
protected:
virtual void _paintShape(QPainter *painter) = 0;
virtual void _paintVertices(QPainter *painter, const QList<int>& selectedVertices = QList<int>());
virtual void _paintShape(QPainter *painter, MapperGLCanvas* canvas) = 0;
virtual void _paintVertices(QPainter *painter, MapperGLCanvas* canvas, const QList<int>& selectedVertices = QList<int>());
QPen getRescaledShapeStroke(MapperGLCanvas* canvas, bool innerStroke=false);
ShapeGraphicsItem* _shapeItem;
};
@@ -58,7 +62,7 @@ public:
virtual ~PolygonControlPainter() {}
protected:
virtual void _paintShape(QPainter *painter);
virtual void _paintShape(QPainter *painter, MapperGLCanvas* canvas);
};
/// Control painter for ellipses.
@@ -69,7 +73,7 @@ public:
virtual ~EllipseControlPainter() {}
protected:
virtual void _paintShape(QPainter *painter);
virtual void _paintShape(QPainter *painter, MapperGLCanvas* canvas);
};
/// Control painter for meshes.
@@ -80,7 +84,7 @@ public:
virtual ~MeshControlPainter() {}
protected:
virtual void _paintShape(QPainter *painter);
virtual void _paintShape(QPainter *painter, MapperGLCanvas* canvas);
};
#endif
-5
View File
@@ -57,11 +57,6 @@ void ShapeGraphicsItem::paint(QPainter *painter,
}
}
QPen ShapeGraphicsItem::getRescaledShapeStroke(bool innerStroke)
{
return QPen(QBrush(MM::CONTROL_COLOR), (innerStroke ? MM::SHAPE_INNER_STROKE_WIDTH : MM::SHAPE_STROKE_WIDTH) / getCanvas()->getZoomFactor());
}
//void VertexGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
//{
// ShapeGraphicsItem* shapeParent = static_cast<ShapeGraphicsItem*>(parentItem());
-7
View File
@@ -101,13 +101,6 @@ protected:
virtual void _postPaint(QPainter *painter, const QStyleOptionGraphicsItem *option)
{ Q_UNUSED(painter); Q_UNUSED(option); }
public:
/**
* Utility function: returns a stroke with rescaled width such that the stroke appears
* invariant to the zoom level (to be used in paint functions).
*/
QPen getRescaledShapeStroke(bool innerStroke=false);
protected:
QWeakPointer<Mapping> _mapping;
QWeakPointer<MShape> _shape;
+1 -1
View File
@@ -78,7 +78,7 @@ unix:!mac {
CONFIG += link_pkgconfig
INCLUDE_PATH +=
PKGCONFIG += \
gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 \
gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 gstreamer-pbutils-1.0 \
liblo \
gl x11
QMAKE_CXXFLAGS += -Wno-unused-result -Wfatal-errors