Is it possible to sync. selection of 2 GraphicScenes while keeping mutliselection ?
-
Hello, My application uses 2 graphic scenes/views, one for 3d view and the other for 2d view. The goal of my app is to select faces of the current 3d model to work on them. When the user select faces on the 3d model, the 3d equivalent faces must also be selected, and reciprocally. I tried to implement that by adding an handler for SelectionChanged events :
connect(dep->scene3d, &QGraphicsScene::selectionChanged, this, &MainWindow::SelectionDansScene3D); connect(dep->scene2d, &QGraphicsScene::selectionChanged, this, &MainWindow::SelectionDansScene2D);
the handlers are :
void MainWindow::SelectionDansScene3D() { if (!selEnCours) { dep->scene2d->clearSelection(); selEnCours = true; for(auto&& i : dep->scene3d->selectedItems()) { int ni = i->data(0).toInt(); for(auto && j : dep->t2d) { if (ni == j->id) { j->setSelected(true); break; } } } selEnCours = false; } } void MainWindow::SelectionDansScene2D() { if (!selEnCours) { dep->scene3d->clearSelection(); selEnCours = true; for(auto&& i : dep->scene2d->selectedItems()) { int ni = i->data(0).toInt(); for(auto && j : dep->scene3d->items()) { int nj = j->data(0).toInt(); if (ni == nj) { auto v = dep->meshModel->faces[ni].voisins; qDebug() << "sel2D : " << ni << " - " << nj << " (" << v[0].nF << ", " << v[1].nF << ", " << v[2].nF << ")"; j->setSelected(true); } } } selEnCours = false; } }
But with those event handlers, it is no more possible to multi select using the mouse (it works using the rubberband), and when I move the 3d scene I lose the selection (I added a list where I save the current selection and retrieve it after I redraw the 3d scene but it doesn't work with SelectionChanged events handlers) . After I disabled those handlers I can both multi select with the mouse and the current selection remains when I rotate the 3d view. Is there something I can do to have those lost functionnalities ?
-