added first version of LINT to the editor
fixed issue with incorrect stairs
This commit is contained in:
92
mapview/2D/MapView2D.cpp
Normal file
92
mapview/2D/MapView2D.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "2D/MapView2D.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QMouseEvent>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "model/MapModelElement.h"
|
||||
#include "model/MapModel.h"
|
||||
|
||||
MapView2D::MapView2D(QWidget* parent) : QOpenGLWidget(parent) {
|
||||
|
||||
// openGL params
|
||||
QSurfaceFormat format;
|
||||
format.setDepthBufferSize(24);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setSamples(1);
|
||||
// format.setVersion(3, 2);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
setFormat(format);
|
||||
|
||||
// receive mouse-move even when mouse is not down
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
// defaults
|
||||
s.setScale(5);
|
||||
|
||||
}
|
||||
|
||||
void MapView2D::paintGL() {
|
||||
|
||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||
f->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
QPainter qp(this);
|
||||
Painter p(s, &qp, width(), height());
|
||||
s.setScreenSize(width(), height());
|
||||
|
||||
// background tools
|
||||
tools.paintBefore(this, p);
|
||||
|
||||
// render all visible elements
|
||||
qp.setRenderHint( QPainter::Antialiasing, true );
|
||||
for (MapModelElement* el : getModel()->getVisibleElements()) {
|
||||
if (el->getMV2D()) {el->getMV2D()->paint(p);}
|
||||
}
|
||||
qp.setRenderHint( QPainter::Antialiasing, false );
|
||||
|
||||
// foreground tools
|
||||
tools.paintAfter(this, p);
|
||||
|
||||
}
|
||||
|
||||
void MapView2D::initializeGL() {
|
||||
|
||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||
f->glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
}
|
||||
|
||||
void MapView2D::resizeGL() {
|
||||
// TODO ?
|
||||
}
|
||||
|
||||
|
||||
void MapView2D::keyPressEvent(QKeyEvent *e) {
|
||||
tools.keyPressEvent(this, e);
|
||||
update();
|
||||
}
|
||||
|
||||
void MapView2D::wheelEvent(QWheelEvent* e) {
|
||||
tools.wheelEvent(this, e);
|
||||
update();
|
||||
}
|
||||
|
||||
void MapView2D::mousePressEvent(QMouseEvent* e) {
|
||||
tools.mousePressEvent(this, e);
|
||||
update();
|
||||
}
|
||||
|
||||
void MapView2D::mouseMoveEvent(QMouseEvent* e) {
|
||||
tools.mouseMoveEvent(this, e);
|
||||
update();
|
||||
}
|
||||
|
||||
void MapView2D::mouseReleaseEvent(QMouseEvent* e) {
|
||||
tools.mouseReleaseEvent(this, e);
|
||||
update();
|
||||
}
|
||||
Reference in New Issue
Block a user