From 16f381ee86ae5657c44ca4aeca33bc0183c395d0 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Thu, 13 Oct 2016 09:05:59 +0000 Subject: [PATCH] - on mesh loading the best rendering tab parameters (according to the mesh primitive) is set by default --- src/meshlab/layerDialog.cpp | 28 ++++++++++++++++++++++++++++ src/meshlab/layerDialog.h | 1 + src/meshlab/mainwindow_RunTime.cpp | 13 +++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index 936fa3d81..c233dc85b 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -781,6 +781,34 @@ void LayerDialog::reset() _applytovis->setChecked(false); } +void LayerDialog::setCurrentTab(const MLRenderingData& dt) +{ + if ((mw == NULL) || (mw->meshDoc() == NULL) || (mw->meshDoc()->mm() == NULL)) + return; + MLRenderingAction* act = NULL; + int id = mw->meshDoc()->mm()->id(); + if (dt.isPrimitiveActive(MLRenderingData::PR_SOLID)) + { + act = new MLRenderingSolidAction(id, NULL); + } + else + { + if (dt.isPrimitiveActive(MLRenderingData::PR_WIREFRAME_EDGES)) + { + act = new MLRenderingWireAction(id, NULL); + } + else + { + if (dt.isPrimitiveActive(MLRenderingData::PR_POINTS)) + { + act = new MLRenderingPointsAction(id, NULL); + } + } + } + actionActivated(act); + delete act; +} + void LayerDialog::updateRenderingParametersTab(int meshid,const MLRenderingData& dt ) { if (_tabw != NULL) diff --git a/src/meshlab/layerDialog.h b/src/meshlab/layerDialog.h index f99d724ea..e5f101e08 100644 --- a/src/meshlab/layerDialog.h +++ b/src/meshlab/layerDialog.h @@ -117,6 +117,7 @@ public: void updateDecoratorParsView(); void updateRenderingParametersTab(int meshid,const MLRenderingData& dt); void reset(); + void setCurrentTab(const MLRenderingData& dt); MLRenderingParametersTab* createRenderingParametersTab(); protected: void keyPressEvent ( QKeyEvent * event ); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 836eedfce..1c86fefab 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -2717,8 +2717,17 @@ bool MainWindow::importMeshWithLayerManagement(QString fileName) globrendtoolbar->setEnabled(false); bool res = importMesh(fileName,false); globrendtoolbar->setEnabled(true); - if (layerDialog != NULL) - showLayerDlg(layervisible || meshDoc()->meshList.size()); + if (layerDialog != NULL) + { + showLayerDlg(layervisible || meshDoc()->meshList.size()); + MLSceneGLSharedDataContext* cont = currentViewContainer()->sharedDataContext(); + if ((cont != NULL) && (GLA() != NULL) && (meshDoc() != NULL) && (meshDoc()->mm() != NULL)) + { + MLRenderingData dt; + cont->getRenderInfoPerMeshView(meshDoc()->mm()->id(), GLA()->context(), dt); + layerDialog->setCurrentTab(dt); + } + } return res; }