mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Merge branch 'develop' into osc-fix-july-2014
This commit is contained in:
+22
-17
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user