focused elements always on top

indicate connected walls
fixes int/float issues
refactoring
This commit is contained in:
2018-07-22 17:33:55 +02:00
parent c4fce6c90d
commit 423fbfc545
6 changed files with 121 additions and 69 deletions

View File

@@ -39,8 +39,8 @@ MapView2D::MapView2D(QWidget* parent) : QOpenGLWidget(parent) {
void MapView2D::paintGL() {
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glClear(GL_COLOR_BUFFER_BIT);
// QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
// f->glClear(GL_COLOR_BUFFER_BIT);
QPainter qp(this);
Painter p(s, &qp, width(), height());
@@ -50,19 +50,34 @@ void MapView2D::paintGL() {
tools.paintBefore(this, p);
std::vector<MV2DElement*> normal;
std::vector<MV2DElement*> focused;
// get all visible elements that can be rendered
// group them whether they currently have focus or not
for (MapModelElement* el : getModel()->getVisibleElements()) {
if (el->getMV2D()) {
if (el->getMV2D()->hasFocus()) {
focused.push_back(el->getMV2D());
} else {
normal.push_back(el->getMV2D());
}
}
}
qp.setRenderHint( QPainter::Antialiasing, true );
// render all visible elements. 1st run
for (MapModelElement* el : getModel()->getVisibleElements()) {
if (el->getMV2D()) {el->getMV2D()->paint(p);}
}
// 2 layer rendering (paint, paintAfter), only UNFOCUSED elements
for (MV2DElement* e : normal) {e->paint(p);}
for (MV2DElement* e : normal) {e->paintAfter(p);}
// render all visible elements. 2nd run
for (MapModelElement* el : getModel()->getVisibleElements()) {
if (el->getMV2D()) {el->getMV2D()->paintAfter(p);}
}
// 2 layer rendering (paint, paintAfter), only FOCUSED elements
for (MV2DElement* e : focused) {e->paint(p);}
for (MV2DElement* e : focused) {e->paintAfter(p);}
qp.setRenderHint( QPainter::Antialiasing, false );
//qp.setRenderHint( QPainter::Antialiasing, false );
// foreground tools
tools.paintAfter(this, p);