From 8f42ebb7d04d670d0bbd2fba14f047cae5c2960b Mon Sep 17 00:00:00 2001 From: Marco Callieri Date: Thu, 7 Jun 2018 14:13:27 +0200 Subject: [PATCH] Store & recall view and visibiliy state still dirty, but works --- src/meshlab/layerDialog.cpp | 177 ++++++++++++++++++++++++++++++---- src/meshlab/layerDialog.h | 7 +- src/meshlab/ui/layerDialog.ui | 77 ++++++++++++++- 3 files changed, 236 insertions(+), 25 deletions(-) diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index 0b72a16c4..4f8f8c274 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -80,11 +80,15 @@ LayerDialog::LayerDialog(QWidget *parent ) // state buttons isRecording = false; - W1 = W2 = W3 = W4 = ""; + viewState[0] = viewState[1] = viewState[2] = viewState[3] = ""; connect(ui->bW1, SIGNAL(clicked()), this, SLOT(clickW1())); connect(ui->bW2, SIGNAL(clicked()), this, SLOT(clickW2())); connect(ui->bW3, SIGNAL(clicked()), this, SLOT(clickW3())); connect(ui->bW4, SIGNAL(clicked()), this, SLOT(clickW4())); + connect(ui->bV1, SIGNAL(clicked()), this, SLOT(clickV1())); + connect(ui->bV2, SIGNAL(clicked()), this, SLOT(clickV2())); + connect(ui->bV3, SIGNAL(clicked()), this, SLOT(clickV3())); + connect(ui->bV4, SIGNAL(clicked()), this, SLOT(clickV4())); this->setContextMenuPolicy(Qt::CustomContextMenu); ui->meshTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -135,68 +139,201 @@ void LayerDialog::clickW1() { if (isRecording) { - W1 = mw->GLA()->viewToText(); + viewState[0] = mw->GLA()->viewToText(); isRecording = false; ui->bW1->setText(QChar(0x2460)); + mw->meshDoc()->Log.Log(0, "Stored View #1"); + } + else if (viewState[0] != "") + { + QDomDocument doc("StringDoc"); + doc.setContent(viewState[0]); + mw->GLA()->loadViewFromViewStateFile(doc); + mw->meshDoc()->Log.Log(0, "Restored View #1"); } else - if (W1 != "") - { - QDomDocument doc("StringDoc"); - doc.setContent(W1); - mw->GLA()->loadViewFromViewStateFile(doc); - } + mw->meshDoc()->Log.Log(0, "No View to Restore"); } void LayerDialog::clickW2() { if (isRecording) { - W2 = mw->GLA()->viewToText(); + viewState[1] = mw->GLA()->viewToText(); isRecording = false; ui->bW2->setText(QChar(0x2461)); + mw->meshDoc()->Log.Log(0, "Stored View #2"); } - else - if (W2 != "") + else if (viewState[1] != "") { QDomDocument doc("StringDoc"); - doc.setContent(W2); + doc.setContent(viewState[1]); mw->GLA()->loadViewFromViewStateFile(doc); + mw->meshDoc()->Log.Log(0, "Restored View #2"); } + else + mw->meshDoc()->Log.Log(0, "No View to Restore"); } void LayerDialog::clickW3() { if (isRecording) { - W3 = mw->GLA()->viewToText(); + viewState[2] = mw->GLA()->viewToText(); isRecording = false; ui->bW3->setText(QChar(0x2462)); + mw->meshDoc()->Log.Log(0, "Stored View #3"); } - else - if (W3 != "") + else if (viewState[2] != "") { QDomDocument doc("StringDoc"); - doc.setContent(W3); + doc.setContent(viewState[2]); mw->GLA()->loadViewFromViewStateFile(doc); + mw->meshDoc()->Log.Log(0, "Restored View #3"); } + else + mw->meshDoc()->Log.Log(0, "No View to Restore"); } void LayerDialog::clickW4() { if (isRecording) { - W4 = mw->GLA()->viewToText(); + viewState[3] = mw->GLA()->viewToText(); isRecording = false; ui->bW4->setText(QChar(0x2463)); + mw->meshDoc()->Log.Log(0, "Stored View #4"); } - else - if (W4 != "") + else if (viewState[3] != "") { QDomDocument doc("StringDoc"); - doc.setContent(W4); + doc.setContent(viewState[3]); mw->GLA()->loadViewFromViewStateFile(doc); + mw->meshDoc()->Log.Log(0, "Restored View #4"); } + else + mw->meshDoc()->Log.Log(0, "No View to Restore"); +} + +void LayerDialog::clickV1() +{ + MeshDocument *md = mw->meshDoc(); + if (isRecording) + { + visibilityState[0].clear(); + foreach(MeshModel *mp, md->meshList) + { + visibilityState[0].insert(mp->id(), mp->isVisible()); + } + isRecording = false; + ui->bV1->setText(QChar(0x2460)); + mw->meshDoc()->Log.Log(0, "Stored Visibility #1"); + } + else if (!visibilityState[0].isEmpty()) + { + QMapIterator i(visibilityState[0]); + while (i.hasNext()) { + i.next(); + if (md->getMesh(i.key()) != NULL) + mw->GLA()->meshSetVisibility(md->getMesh(i.key()), i.value()); + } + updatePerMeshItemVisibility(); + updatePerMeshItemSelectionStatus(); + mw->GLA()->update(); + mw->meshDoc()->Log.Log(0, "Restored Visibility #1"); + } + else + mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); +} +void LayerDialog::clickV2() +{ + MeshDocument *md = mw->meshDoc(); + if (isRecording) + { + visibilityState[1].clear(); + foreach(MeshModel *mp, md->meshList) + { + visibilityState[1].insert(mp->id(), mp->isVisible()); + } + isRecording = false; + ui->bV2->setText(QChar(0x2461)); + mw->meshDoc()->Log.Log(0, "Stored Visibility #2"); + } + else if (!visibilityState[1].isEmpty()) + { + QMapIterator i(visibilityState[1]); + while (i.hasNext()) { + i.next(); + if (md->getMesh(i.key()) != NULL) + mw->GLA()->meshSetVisibility(md->getMesh(i.key()), i.value()); + } + updatePerMeshItemVisibility(); + updatePerMeshItemSelectionStatus(); + mw->GLA()->update(); + mw->meshDoc()->Log.Log(0, "Restored Visibility #2"); + } + else + mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); +} +void LayerDialog::clickV3() +{ + MeshDocument *md = mw->meshDoc(); + if (isRecording) + { + visibilityState[2].clear(); + foreach(MeshModel *mp, md->meshList) + { + visibilityState[2].insert(mp->id(), mp->isVisible()); + } + isRecording = false; + ui->bV3->setText(QChar(0x2462)); + mw->meshDoc()->Log.Log(0, "Stored Visibility #3"); + } + else if (!visibilityState[2].isEmpty()) + { + QMapIterator i(visibilityState[2]); + while (i.hasNext()) { + i.next(); + if (md->getMesh(i.key()) != NULL) + mw->GLA()->meshSetVisibility(md->getMesh(i.key()), i.value()); + } + updatePerMeshItemVisibility(); + updatePerMeshItemSelectionStatus(); + mw->GLA()->update(); + mw->meshDoc()->Log.Log(0, "Restored Visibility #3"); + } + else + mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); +} +void LayerDialog::clickV4() +{ + MeshDocument *md = mw->meshDoc(); + if (isRecording) + { + visibilityState[3].clear(); + foreach(MeshModel *mp, md->meshList) + { + visibilityState[3].insert(mp->id(), mp->isVisible()); + } + isRecording = false; + ui->bV4->setText(QChar(0x2463)); + mw->meshDoc()->Log.Log(0, "Stored Visibility #4"); + } + else if (!visibilityState[3].isEmpty()) + { + QMapIterator i(visibilityState[3]); + while (i.hasNext()) { + i.next(); + if (md->getMesh(i.key()) != NULL) + mw->GLA()->meshSetVisibility(md->getMesh(i.key()), i.value()); + } + updatePerMeshItemVisibility(); + updatePerMeshItemSelectionStatus(); + mw->GLA()->update(); + mw->meshDoc()->Log.Log(0, "Restored Visibility #4"); + } + else + mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); } void LayerDialog::enterEvent(QEvent* /*event*/) diff --git a/src/meshlab/layerDialog.h b/src/meshlab/layerDialog.h index d6bdae4f2..d0dc15598 100644 --- a/src/meshlab/layerDialog.h +++ b/src/meshlab/layerDialog.h @@ -139,6 +139,10 @@ public slots: void clickW2(); void clickW3(); void clickW4(); + void clickV1(); + void clickV2(); + void clickV3(); + void clickV4(); private slots: /*WARNING!!! ADDED just to avoid usual mac strange behavior. Please, avoid to use it if it's not absolutely necessary*/ @@ -167,7 +171,8 @@ private: // state buttons bool isRecording; - QString W1, W2, W3, W4; + QString viewState[4]; + QMap visibilityState[4]; QTreeWidgetItem* _docitem; int _previd; diff --git a/src/meshlab/ui/layerDialog.ui b/src/meshlab/ui/layerDialog.ui index fd09c5848..0acfcf385 100644 --- a/src/meshlab/ui/layerDialog.ui +++ b/src/meshlab/ui/layerDialog.ui @@ -55,11 +55,12 @@ 9 75 + false true - CTRL-click to set view, click to recall + CTRL-click to store view, click to recall 1 @@ -76,7 +77,7 @@ - CTRL-click to set view, click to recall + CTRL-click to store view, click to recall 2 @@ -93,7 +94,7 @@ - CTRL-click to set view, click to recall + CTRL-click to store view, click to recall 3 @@ -110,7 +111,7 @@ - CTRL-click to set view, click to recall + CTRL-click to store view, click to recall 4 @@ -130,6 +131,74 @@ + + + + + 9 + 75 + true + + + + CTRL-click to store layer visibility, click to recall + + + 1 + + + + + + + + 9 + 75 + true + + + + CTRL-click to store layer visibility, click to recall + + + 2 + + + + + + + + 9 + 75 + true + + + + CTRL-click to store layer visibility, click to recall + + + 3 + + + + + + + + 9 + 75 + true + + + + CTRL-click to store layer visibility, click to recall + + + 4 + + +