From bc62ebc63cfea4de7c5ef2a0e31b5d04772b8513 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Thu, 28 Feb 2013 07:10:07 +0000 Subject: [PATCH] Added a per-document decorator that enlighten the current mesh --- .../decorate_base/decorate_base.cpp | 31 +++++++++++++++++++ .../decorate_base/decorate_base.h | 5 ++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/meshlabplugins/decorate_base/decorate_base.cpp b/src/meshlabplugins/decorate_base/decorate_base.cpp index 6f46cd858..7bedb1bf5 100644 --- a/src/meshlabplugins/decorate_base/decorate_base.cpp +++ b/src/meshlabplugins/decorate_base/decorate_base.cpp @@ -53,6 +53,7 @@ QString ExtraMeshDecoratePlugin::decorationInfo(FilterIDType filter) const case DP_SHOW_QUALITY_HISTOGRAM: return tr("Draws a (colored) Histogram of the per vertex/face quality"); case DP_SHOW_CAMERA: return tr("Draw the position of the camera, if present in the current mesh"); case DP_SHOW_TEXPARAM: return tr("Draw an overlayed flattened version of the current mesh that show the current parametrization"); + case DP_SHOW_SELECTED_MESH: return tr("Enlighten the current Mesh"); } assert(0); return QString(); @@ -78,6 +79,7 @@ QString ExtraMeshDecoratePlugin::decorationName(FilterIDType filter) const case DP_SHOW_CAMERA: return tr("Show Camera"); case DP_SHOW_TEXPARAM: return tr("Show UV Tex Param"); case DP_SHOW_QUALITY_HISTOGRAM: return tr("Show Quality Histogram"); + case DP_SHOW_SELECTED_MESH: return tr("Show Current Mesh"); default: assert(0); } @@ -129,6 +131,22 @@ void ExtraMeshDecoratePlugin::decorateDoc(QAction *a, MeshDocument &md, RichPara } } break; + case DP_SHOW_SELECTED_MESH: + { + glPushAttrib(GL_ENABLE_BIT|GL_VIEWPORT_BIT| GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT); + glDisable(GL_LIGHTING); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDepthRange (0.0, 0.9999); + glDepthFunc(GL_LEQUAL); + glPointSize(3); + + glColor4f(1.0f, 1.0f, 1.0f, 0.1f); +// md.mm()->glw.DrawPointsBase(); + md.mm()->render(GLW::DMFlat, GLW::CMNone, GLW::TMNone); + glPopAttrib(); + } break; + case DP_SHOW_AXIS: { CoordinateFrame(md.bbox().Diag()/2.0).Render(gla,painter); @@ -768,6 +786,7 @@ int ExtraMeshDecoratePlugin::getDecorationClass(QAction *action) const case DP_SHOW_TEXPARAM : case DP_SHOW_BOUNDARY_TEX : return ExtraMeshDecoratePlugin::PerMesh; case DP_SHOW_AXIS : return ExtraMeshDecoratePlugin::PerDocument; + case DP_SHOW_SELECTED_MESH : return ExtraMeshDecoratePlugin::PerDocument; } assert (0); return 0; @@ -796,6 +815,18 @@ bool ExtraMeshDecoratePlugin::isDecorationApplicable(QAction *action, const Mesh return true; } +bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshDocument &md, RichParameterSet *rm, GLArea *gla) +{ + switch(ID(action)) + { + case DP_SHOW_AXIS : + case DP_SHOW_CAMERA : + case DP_SHOW_SELECTED_MESH : + return true; + } + return false; +} + bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshModel &m, RichParameterSet *rm, GLArea *gla) { diff --git a/src/meshlabplugins/decorate_base/decorate_base.h b/src/meshlabplugins/decorate_base/decorate_base.h index 20750403d..16855099a 100644 --- a/src/meshlabplugins/decorate_base/decorate_base.h +++ b/src/meshlabplugins/decorate_base/decorate_base.h @@ -54,7 +54,8 @@ class ExtraMeshDecoratePlugin : public QObject, public MeshDecorateInterface DP_SHOW_QUALITY_HISTOGRAM, DP_SHOW_CAMERA, DP_SHOW_TEXPARAM, - DP_SHOW_BOUNDARY_TEX + DP_SHOW_BOUNDARY_TEX, + DP_SHOW_SELECTED_MESH }; @@ -88,6 +89,7 @@ public: DP_SHOW_LABEL << DP_SHOW_CAMERA << DP_SHOW_TEXPARAM << + DP_SHOW_SELECTED_MESH << DP_SHOW_BOUNDARY_TEX; FilterIDType tt; @@ -119,6 +121,7 @@ public: void decorateDoc(QAction *a, MeshDocument &md, RichParameterSet *, GLArea *gla, QPainter *painter, GLLogStream &_log); void decorateMesh(QAction *a, MeshModel &md, RichParameterSet *, GLArea *gla, QPainter *painter, GLLogStream &_log); bool startDecorate(QAction * /*mode*/, MeshModel &/*m*/, RichParameterSet *, GLArea * /*parent*/); + bool startDecorate(QAction * /*mode*/, MeshDocument &/*m*/, RichParameterSet *, GLArea * /*parent*/); bool isDecorationApplicable(QAction *action, const MeshModel& m, QString &ErrorMessage) const; int getDecorationClass(QAction */*action*/) const; void initGlobalParameterSet(QAction *, RichParameterSet &/*globalparam*/);