From a5d5d5eb5614aa007a4e89f85aec627e24dce6e9 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Tue, 8 Oct 2013 17:09:33 +0000 Subject: [PATCH] - Huge Commit! added per mesh rendering mode system! Warning! there is a major drawback with the MeshRenderingInterface plugins. It will be fixed as soon as possible. --- src/common/meshmodel.cpp | 14 +++++++++--- src/common/meshmodel.h | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/common/meshmodel.cpp b/src/common/meshmodel.cpp index 88ead7411..d28dd556a 100644 --- a/src/common/meshmodel.cpp +++ b/src/common/meshmodel.cpp @@ -182,7 +182,7 @@ MeshModel * MeshDocument::addNewMesh(QString fullPath, QString label, bool setAs MeshModel *newMesh = new MeshModel(this,qPrintable(fullPath),newlabel); meshList.push_back(newMesh); emit meshSetChanged(); - + emit meshAdded(newMesh->id()); if(setAsCurrent) this->setCurrentMesh(newMesh->id()); return newMesh; @@ -197,9 +197,11 @@ bool MeshDocument::delMesh(MeshModel *mmToDel) else if (meshList.size() == 0) setCurrentMesh(-1); + int index = mmToDel->id(); delete mmToDel; emit meshSetChanged(); + emit meshRemoved(index); return true; } @@ -711,16 +713,20 @@ bool MeshLabRenderMesh::render(vcg::GLW::DrawMode dm,vcg::GLW::ColorMode colm,vc { if (glw.m != NULL) { + glPushAttrib(GL_ALL_ATTRIB_BITS); glPushMatrix(); glMultMatrix(glw.m->Tr); if( (colm == vcg::GLW::CMPerFace) && (!vcg::tri::HasPerFaceColor(*glw.m)) ) colm=vcg::GLW::CMNone; if( (tm == vcg::GLW::TMPerWedge )&& (!vcg::tri::HasPerWedgeTexCoord(*glw.m)) ) tm=vcg::GLW::TMNone; - if( (tm == vcg::GLW::TMPerWedgeMulti )&& (!vcg::tri::HasPerWedgeTexCoord(*glw.m)) ) + if( (tm == vcg::GLW::TMPerWedgeMulti )&& (!vcg::tri::HasPerWedgeTexCoord(*glw.m))) + tm=vcg::GLW::TMNone; + if( (tm == vcg::GLW::TMPerVert )&& (!vcg::tri::HasPerVertexTexCoord(*glw.m))) tm=vcg::GLW::TMNone; glw.Draw(dm,colm,tm); glPopMatrix(); + glPopAttrib(); return true; } return false; @@ -1006,7 +1012,9 @@ void MeshLabRenderState::copyBack( const int /*id*/,CMeshO& /*mm*/ ) const void MeshLabRenderState::render( const int id,vcg::GLW::DrawMode dm,vcg::GLW::ColorMode cm,vcg::GLW::TextureMode tm ) { lockRenderState(MESH,READ); - _meshmap[id]->render(dm,cm,tm); + QMap::const_iterator it = _meshmap.find(id); + if (it != _meshmap.end()) + it.value()->render(dm,cm,tm); unlockRenderState(MESH); } diff --git a/src/common/meshmodel.h b/src/common/meshmodel.h index b5eff6281..c6f104674 100644 --- a/src/common/meshmodel.h +++ b/src/common/meshmodel.h @@ -142,6 +142,7 @@ public: vcg::GlTrimesh glw; CMeshO cm; + //RenderMode rm; }; /* @@ -424,6 +425,50 @@ public: selectedVert=false; } + inline void setDrawMode(const vcg::GLW::DrawMode dm) + { + drawMode = dm; + } + + inline void setColorMode(const vcg::GLW::ColorMode cm) + { + colorMode = cm; + } + + inline void setTextureMode(const vcg::GLW::TextureMode tm) + { + textureMode = tm; + } + + inline void setLighting(const bool ison) + { + lighting = ison; + } + + inline void setBackFaceCull(const bool ison) + { + backFaceCull = ison; + } + + inline void setDoubleFaceLighting(const bool ison) + { + doubleSideLighting = ison; + } + + inline void setFancyLighting(const bool ison) + { + fancyLighting = ison; + } + + inline void setSelectedFaceRendering(const bool ison) + { + selectedFace = ison; + } + + inline void setSelectedVertRendering(const bool ison) + { + selectedVert = ison; + } }; // end class RenderMode class MeshLabRenderState //: public QObject @@ -632,6 +677,8 @@ private: //the current raster model RasterModel* currentRaster; + + signals: ///whenever the current mesh is changed (e.g. the user click on a different mesh) // this signal will send out with the index of the newest mesh @@ -642,6 +689,8 @@ signals: ///whenever the meshList is changed void meshSetChanged(); + void meshAdded(int index); + void meshRemoved(int index); ///whenever the rasterList is changed void rasterSetChanged();