diff --git a/src/common/interfaces.h b/src/common/interfaces.h index 344fb2c61..ffd553eee 100644 --- a/src/common/interfaces.h +++ b/src/common/interfaces.h @@ -557,6 +557,8 @@ public: //should return a sentence describing what the editing tool does static const QString Info(); + virtual void suggestedRenderingData(MeshModel &/*m*/, MLRenderingData& /*dt*/) {} + // Called when the user press the first time the button virtual bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/,MLSceneGLSharedDataContext* /*cont*/){return true;} virtual bool StartEdit(MeshDocument &md, GLArea *parent,MLSceneGLSharedDataContext* cont) diff --git a/src/common/ml_shared_data_context.cpp b/src/common/ml_shared_data_context.cpp index 8289d13b5..f016e9cd0 100644 --- a/src/common/ml_shared_data_context.cpp +++ b/src/common/ml_shared_data_context.cpp @@ -760,6 +760,7 @@ void MLPoliciesStandAloneFunctions::suggestedDefaultPerViewGLOptions( MLPerViewG tmp._perwire_fixed_color = vcg::Color4b(vcg::Color4b::DarkGray); tmp._persolid_fixed_color = vcg::Color4b(vcg::Color4b::LightGray); tmp._sel_enabled = true; + tmp._peredge_extra_enabled = true; } //void MLPoliciesStandAloneFunctions::bestPrimitiveModalityMaskAfterUpdate( MeshModel* meshmodel,int meshmodelmask,const MLRenderingData::PRIMITIVE_MODALITY_MASK& inputpm,MLRenderingData::PRIMITIVE_MODALITY_MASK& outputpm ) diff --git a/src/meshlab/glarea.cpp b/src/meshlab/glarea.cpp index 30a9ace9a..db13cb472 100644 --- a/src/meshlab/glarea.cpp +++ b/src/meshlab/glarea.cpp @@ -469,7 +469,7 @@ void GLArea::paintEvent(QPaintEvent* /*event*/) iRenderer->Render(currentShader, *this->md(), dt, this); - MLDefaultMeshDecorators defdec; + MLDefaultMeshDecorators defdec(mw()); foreach(MeshModel * mp, this->md()->meshList) { @@ -532,7 +532,7 @@ void GLArea::paintEvent(QPaintEvent* /*event*/) decorInterface->decorateMesh(*it,*mp,this->glas.currentGlobalParamSet,this,&painter,md()->Log); } - MLDefaultMeshDecorators defdec; + MLDefaultMeshDecorators defdec(mw()); datacont->getRenderInfoPerMeshView(mp->id(),context(),curr); defdec.decorateMesh(*mp,curr,&painter,md()->Log); } @@ -613,8 +613,8 @@ void GLArea::paintEvent(QPaintEvent* /*event*/) if (takeSnapTile) pasteTile(); // Finally display HELP if requested - if (isHelpVisible()) displayHelp(); - glFinish(); + if (isHelpVisible()) + displayHelp(); // Draw the log area background // on the bottom of the glArea @@ -644,6 +644,8 @@ void GLArea::paintEvent(QPaintEvent* /*event*/) painter.endNativePainting(); //glFinish(); //doneCurrent(); + glFlush(); + glFinish(); } void GLArea::displayMatrix(QPainter *painter, QRect areaRect) @@ -1008,7 +1010,7 @@ void GLArea::updateAllPerMeshDecorators() if (shared == NULL) return; - MLDefaultMeshDecorators defdec; + MLDefaultMeshDecorators defdec(mw()); for(MeshModel* mm = mdoc->nextMesh();mm != NULL;mm = mdoc->nextMesh(mm)) { MLRenderingData dt; @@ -1021,13 +1023,43 @@ void GLArea::updateAllPerMeshDecorators() void GLArea::setCurrentEditAction(QAction *editAction) { + if ((parentmultiview == NULL) || (parentmultiview->sharedDataContext() == NULL)) + return; + makeCurrent(); assert(editAction); currentEditor = editAction; iEdit = actionToMeshEditMap.value(currentEditor); - assert(iEdit); + if (iEdit == NULL) + return; + lastModelEdited = this->md()->mm(); + + MLRenderingData dt; + if (iEdit->isSingleMeshEdit()) + { + if (md()->mm() != NULL) + { + parentmultiview->sharedDataContext()->getRenderInfoPerMeshView(md()->mm()->id(), context(), dt); + iEdit->suggestedRenderingData(*(md()->mm()), dt); + parentmultiview->sharedDataContext()->setRenderingDataPerMeshView(md()->mm()->id(), context(), dt); + } + } + else + { + foreach(MeshModel* mm, md()->meshList) + { + if (mm != NULL) + { + parentmultiview->sharedDataContext()->getRenderInfoPerMeshView(mm->id(), context(), dt); + iEdit->suggestedRenderingData(*(mm), dt); + parentmultiview->sharedDataContext()->setRenderingDataPerMeshView(mm->id(), context(), dt); + } + } + } + if (mw() != NULL) + mw()->updateLayerTable(); if (!iEdit->StartEdit(*this->md(), this,parentmultiview->sharedDataContext())) { //iEdit->EndEdit(*(this->md()->mm()), this); @@ -1036,7 +1068,7 @@ void GLArea::setCurrentEditAction(QAction *editAction) else { Logf(GLLogStream::SYSTEM,"Started Mode %s", qPrintable(currentEditor->text())); - if(mm()!=NULL) + if(mm()!=NULL) mm()->meshModified() = true; else assert(!iEdit->isSingleMeshEdit()); } diff --git a/src/meshlab/glarea.h b/src/meshlab/glarea.h index 09b37ab04..99ee07cdc 100644 --- a/src/meshlab/glarea.h +++ b/src/meshlab/glarea.h @@ -41,6 +41,7 @@ #include "snapshotsetting.h" #include "multiViewer_Container.h" #include "ml_selection_buffers.h" +#include "ml_default_decorators.h" #define SSHOT_BYTES_PER_PIXEL 4 @@ -82,7 +83,7 @@ public: MeshModel* mm = md()->getMesh(meshid); if (mm != NULL) { - CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator::GetPerMeshAttribute(mm->cm, "SelectionBuffers"); + CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator::GetPerMeshAttribute(mm->cm, MLDefaultMeshDecorators::selectionAttName()); if ((selbufhand() != NULL) && (facesel)) selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERFACE_SEL); @@ -92,6 +93,19 @@ public: } } + /*WARNING!!!!! HORRIBLE THING!!!!! Added just to avoid to include the multiViewer_container.cpp file in a MeshLab plugins project in case it needs to update all the GLArea and not just the one passed as parameter*/ + + void updateAllSiblingsGLAreas() + { + if (mvc() == NULL) + return; + foreach(GLArea* viewer, mvc()->viewerList) + { + if (viewer != NULL) + viewer->update(); + } + } + void requestForRenderingAttsUpdate( int meshid,MLRenderingData::ATT_NAMES attname ) { if (parentmultiview != NULL) diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index 4098e9236..c9f338da6 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -843,6 +843,7 @@ MeshTreeWidgetItem::MeshTreeWidgetItem(MeshModel* meshmodel,QTreeWidget* tree,ML tree->setItemWidget(this,3,_rendertoolbar); setText(2, meshName); + setToolTip(2, inf.absoluteFilePath()); _meshid = meshmodel->id(); } } diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index ee1970343..63e69ada5 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -122,6 +122,7 @@ public slots: bool openProject(QString fileName=QString()); bool appendProject(QString fileName=QString()); void updateCustomSettings(); + void updateLayerDialog(); private slots: @@ -146,6 +147,8 @@ public: void updateRenderingDataAccordingToActions(int meshid,const QList& acts); void updateRenderingDataAccordingToAction( int meshid,MLRenderingAction* act); + unsigned int viewsRequiringRenderingActions(int meshid,MLRenderingAction* act); + void updateSharedContextDataAfterFilterExecution(int postcondmask,int fclasses,bool& newmeshcreated); private slots: //////////// Slot Menu File ////////////////////// @@ -188,7 +191,6 @@ private slots: void updateStdDialog(); void updateXMLStdDialog(); void enableDocumentSensibleActionsContainer(const bool enable); - void updateLayerDialog(); //void updatePerViewApplicationStatus(); void setSplit(QAction *qa); void setUnsplit(); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index e1fa49d04..e5ef0f092 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -3384,7 +3384,7 @@ void MainWindow::updateRenderingDataAccordingToActions(int meshid,const QListgetMesh(meshid); if (mm != NULL) { - MLDefaultMeshDecorators dec; + MLDefaultMeshDecorators dec(this); dec.updateMeshDecorationData(*mm,olddt,dt); } GLA()->update(); @@ -3403,8 +3403,29 @@ void MainWindow::updateRenderingDataAccordingToAction( int meshid,MLRenderingAct MeshModel* mm = meshDoc()->getMesh(meshid); if (mm != NULL) { - MLDefaultMeshDecorators dec; + MLDefaultMeshDecorators dec(this); dec.updateMeshDecorationData(*mm,olddt,dt); } GLA()->update(); +} + +unsigned int MainWindow::viewsRequiringRenderingActions(int meshid, MLRenderingAction* act) +{ + unsigned int res = 0; + MultiViewer_Container* cont = currentViewContainer(); + if (cont != NULL) + { + MLSceneGLSharedDataContext* share = cont->sharedDataContext(); + if (share != NULL) + { + foreach(GLArea* area,cont->viewerList) + { + MLRenderingData dt; + share->getRenderInfoPerMeshView(meshid, area->context(), dt); + if (act->isRenderingDataEnabled(dt)) + ++res; + } + } + } + return res; } \ No newline at end of file diff --git a/src/meshlab/ml_default_decorators.cpp b/src/meshlab/ml_default_decorators.cpp index f2ce56eff..7281d3e1d 100644 --- a/src/meshlab/ml_default_decorators.cpp +++ b/src/meshlab/ml_default_decorators.cpp @@ -27,8 +27,15 @@ #include #include +#include "mainwindow.h" #include "ml_selection_buffers.h" +MLDefaultMeshDecorators::MLDefaultMeshDecorators(MainWindow* mw) + :_mw(mw) +{ + +} + bool MLDefaultMeshDecorators::updateMeshDecorationData( MeshModel& mesh,const MLRenderingData& previousdata,const MLRenderingData& currentdata ) { MLPerViewGLOptions oldopts; @@ -38,25 +45,51 @@ bool MLDefaultMeshDecorators::updateMeshDecorationData( MeshModel& mesh,const ML if ((!oldvalid) || (!currentvalid)) return false; - /*the boolean conditions should make the following code lines mutually exclusive.....hopefully*/ - initBoundaryDecoratorData(mesh,currentopts._peredge_edgeboundary_enabled && !oldopts._peredge_edgeboundary_enabled, - currentopts._peredge_faceboundary_enabled && !oldopts._peredge_faceboundary_enabled); - cleanBoundaryDecoratorData(mesh,!currentopts._peredge_edgeboundary_enabled && oldopts._peredge_edgeboundary_enabled, - !currentopts._peredge_faceboundary_enabled && oldopts._peredge_faceboundary_enabled); + /*bool extraswitchon = currentopts._peredge_extra_enabled && !oldopts._peredge_extra_enabled; + bool extraswitchoff = !currentopts._peredge_extra_enabled && oldopts._peredge_extra_enabled; + + //the boolean conditions should make the following code lines mutually exclusive.....hopefully + initBoundaryDecoratorData(mesh,(extraswitchon || (currentopts._peredge_edgeboundary_enabled && !oldopts._peredge_edgeboundary_enabled)), + (extraswitchon || (currentopts._peredge_faceboundary_enabled && !oldopts._peredge_faceboundary_enabled))); + cleanBoundaryDecoratorData(mesh,(extraswitchoff || (!currentopts._peredge_edgeboundary_enabled && oldopts._peredge_edgeboundary_enabled)), + (extraswitchoff || (!currentopts._peredge_faceboundary_enabled && oldopts._peredge_faceboundary_enabled))); - if (currentopts._peredge_edgemanifold_enabled && !oldopts._peredge_edgemanifold_enabled) + if (extraswitchon || (currentopts._peredge_edgemanifold_enabled && !oldopts._peredge_edgemanifold_enabled)) initNonManifEdgeDecoratorData(mesh); else - if (!currentopts._peredge_edgemanifold_enabled && oldopts._peredge_edgemanifold_enabled) + if (extraswitchoff || (!currentopts._peredge_edgemanifold_enabled && oldopts._peredge_edgemanifold_enabled)) cleanNonManifEdgeDecoratorData(mesh); - if (currentopts._peredge_text_boundary_enabled && !oldopts._peredge_text_boundary_enabled) + if (extraswitchon || (currentopts._peredge_text_boundary_enabled && !oldopts._peredge_text_boundary_enabled)) initBoundaryTextDecoratorData(mesh); else - if (!currentopts._peredge_text_boundary_enabled && oldopts._peredge_text_boundary_enabled) - cleanBoundaryTextDecoratorData(mesh); + if (extraswitchoff || (!currentopts._peredge_text_boundary_enabled && oldopts._peredge_text_boundary_enabled)) + cleanBoundaryTextDecoratorData(mesh);*/ + initBoundaryDecoratorData(mesh,currentopts._peredge_edgeboundary_enabled && !oldopts._peredge_edgeboundary_enabled, + currentopts._peredge_faceboundary_enabled && !oldopts._peredge_faceboundary_enabled); + cleanBoundaryDecoratorData(mesh,!currentopts._peredge_edgeboundary_enabled && oldopts._peredge_edgeboundary_enabled, + !currentopts._peredge_faceboundary_enabled && oldopts._peredge_faceboundary_enabled); + + + if (currentopts._peredge_edgemanifold_enabled && !oldopts._peredge_edgemanifold_enabled) + initNonManifEdgeDecoratorData(mesh); + else + if (!currentopts._peredge_edgemanifold_enabled && oldopts._peredge_edgemanifold_enabled) + cleanNonManifEdgeDecoratorData(mesh); + + if (currentopts._peredge_vertmanifold_enabled && !oldopts._peredge_vertmanifold_enabled) + initNonManifVertDecoratorData(mesh); + else + if (!currentopts._peredge_vertmanifold_enabled && oldopts._peredge_vertmanifold_enabled) + cleanNonManifVertDecoratorData(mesh); + + if (currentopts._peredge_text_boundary_enabled && !oldopts._peredge_text_boundary_enabled) + initBoundaryTextDecoratorData(mesh); + else + if (!currentopts._peredge_text_boundary_enabled && oldopts._peredge_text_boundary_enabled) + cleanBoundaryTextDecoratorData(mesh); initSelectionDecoratorData(mesh, currentopts._vertex_sel && !oldopts._vertex_sel, currentopts._face_sel && !oldopts._face_sel); cleanSelectionDecoratorData(mesh,!currentopts._vertex_sel && oldopts._vertex_sel, !currentopts._face_sel && oldopts._face_sel); @@ -71,15 +104,19 @@ bool MLDefaultMeshDecorators::initMeshDecorationData( MeshModel& m,const MLRende if (!valid) return false; - initBoundaryDecoratorData(m,opts._peredge_edgeboundary_enabled,opts._peredge_faceboundary_enabled); + //if (opts._peredge_extra_enabled) + //{ + initBoundaryDecoratorData(m, opts._peredge_edgeboundary_enabled, opts._peredge_faceboundary_enabled); - if (opts._peredge_edgemanifold_enabled) - initNonManifEdgeDecoratorData(m); + if (opts._peredge_edgemanifold_enabled) + initNonManifEdgeDecoratorData(m); - if (opts._peredge_text_boundary_enabled) - initBoundaryTextDecoratorData(m); - - initSelectionDecoratorData(m,opts._vertex_sel,opts._face_sel); + if (opts._peredge_text_boundary_enabled) + initBoundaryTextDecoratorData(m); + //} + + initSelectionDecoratorData(m, opts._vertex_sel, opts._face_sel); + return true; } @@ -98,7 +135,8 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData& CMeshO::PerMeshAttributeHandle< std::vector > bvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,boundaryVertAttName()); CMeshO::PerMeshAttributeHandle< std::vector > beH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,boundaryEdgeAttName()); CMeshO::PerMeshAttributeHandle< std::vector > bfH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,boundaryFaceAttName()); - drawLineVector(beH()); + if (opts._peredge_edgeboundary_enabled) + drawLineVector(beH()); if(opts._peredge_faceboundary_enabled) drawTriVector(bfH()); drawDotVector(bvH(),5); @@ -127,13 +165,13 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData& if (opts._peredge_vertmanifold_enabled) { // Note the standard way for adding extra per-mesh data using the per-mesh attributes. - CMeshO::PerMeshAttributeHandle< std::vector > vvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"NonManifVertVertVector"); - CMeshO::PerMeshAttributeHandle< std::vector > tvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"NonManifVertTriVector"); + CMeshO::PerMeshAttributeHandle< std::vector > vvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,nonManifVertAttName()); + CMeshO::PerMeshAttributeHandle< std::vector > tvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,nonManifVertFaceAttName()); drawDotVector(vvH()); drawTriVector(tvH()); QString inf; - inf += "" + QString::number(vvH().size()) + " non manifold vertices
" + QString::number(tvH().size()) + " faces over non manifold edges"; + inf += "" + QString::number(vvH().size()) + " non manifold vertices
" + QString::number(tvH().size() / 3) + " faces over non manifold edges"; log.RealTimeLog("Non Manifold Vertices",m.shortName(),inf); } @@ -199,7 +237,6 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData& drawQuotedBox(m,painter,qf); } } - glFinish(); } @@ -453,6 +490,9 @@ bool MLDefaultMeshDecorators::cleanMeshDecorationData( MeshModel& mesh,const MLR if (opts._peredge_text_boundary_enabled) cleanBoundaryTextDecoratorData(mesh); + + if (opts._vertex_sel || opts._face_sel) + cleanSelectionDecoratorData(mesh, !opts._vertex_sel, !opts._face_sel); return true; } @@ -463,12 +503,18 @@ void MLDefaultMeshDecorators::initBoundaryDecoratorData( MeshModel& m,bool edgeb CMeshO::PerMeshAttributeHandle< std::vector > bvH; bvH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm,boundaryVertAttName()); + CMeshO::PerMeshAttributeHandle< std::vector > beH; - if (edgeboundary) - beH= vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm,boundaryEdgeAttName()); + if (edgeboundary) + { + beH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, boundaryEdgeAttName()); + } + CMeshO::PerMeshAttributeHandle< std::vector > bfH; - if (faceboundary) - bfH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm,boundaryFaceAttName()); + if (faceboundary) + { + bfH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, boundaryFaceAttName()); + } std::vector *BVp = &bvH(); std::vector *BEp = NULL; @@ -537,12 +583,45 @@ void MLDefaultMeshDecorators::initBoundaryDecoratorData( MeshModel& m,bool edgeb void MLDefaultMeshDecorators::cleanBoundaryDecoratorData( MeshModel& m,bool edgeboundary,bool faceboundary) { - if (edgeboundary && faceboundary) - vcg::tri::Allocator::DeletePerMeshAttribute(m.cm,boundaryVertAttName()); - if (edgeboundary) - vcg::tri::Allocator::DeletePerMeshAttribute(m.cm,boundaryEdgeAttName()); + if (_mw == NULL) + return; + + MLRenderingEdgeBoundaryAction eact(m.id(), NULL); + unsigned int edgerequview = _mw->viewsRequiringRenderingActions(m.id(), &eact); + if (edgeboundary) + { + if (edgerequview == 0) + { + CMeshO::PerMeshAttributeHandle< std::vector > beH; + beH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, boundaryEdgeAttName()); + if (beH._handle != NULL) + beH().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, beH); + } + } + + MLRenderingFaceBoundaryAction fact(m.id(), NULL); + unsigned int facerequview = _mw->viewsRequiringRenderingActions(m.id(), &fact); if (faceboundary) - vcg::tri::Allocator::DeletePerMeshAttribute(m.cm,boundaryFaceAttName()); + { + if (facerequview == 0) + { + CMeshO::PerMeshAttributeHandle< std::vector > beH; + beH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, boundaryFaceAttName()); + if (beH._handle != NULL) + beH().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, beH); + } + } + + if ((facerequview == 0) && (edgerequview == 0)) + { + CMeshO::PerMeshAttributeHandle< std::vector > beH; + beH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, boundaryVertAttName()); + if (beH._handle != NULL) + beH().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, beH); + } } void MLDefaultMeshDecorators::initSelectionDecoratorData(MeshModel & mm, bool vertsel, bool facesel) @@ -554,20 +633,28 @@ void MLDefaultMeshDecorators::initSelectionDecoratorData(MeshModel & mm, bool ve if (vertsel) selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERVERT_SEL); if (facesel) - selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERFACE_SEL); + selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERFACE_SEL); } void MLDefaultMeshDecorators::cleanSelectionDecoratorData(MeshModel& mm, bool vertsel, bool facesel) { - CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator::GetPerMeshAttribute(mm.cm, selectionAttName()); - MLSelectionBuffers* tmp = selbufhand(); - if (vertsel && (tmp != NULL)) - tmp->deallocateBuffer(MLSelectionBuffers::ML_PERVERT_SEL); + if (_mw == NULL) + return; - if (facesel && (tmp != NULL)) + CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator::GetPerMeshAttribute(mm.cm, selectionAttName()); + MLSelectionBuffers* tmp = selbufhand(); + + MLRenderingVertSelectionAction vact(mm.id(), NULL); + unsigned int vertselreqview = _mw->viewsRequiringRenderingActions(mm.id(), &vact); + if (vertsel && (tmp != NULL) && (vertselreqview == 0)) + tmp->deallocateBuffer(MLSelectionBuffers::ML_PERVERT_SEL); + + MLRenderingFaceSelectionAction fact(mm.id(), NULL); + unsigned int faceselreqview = _mw->viewsRequiringRenderingActions(mm.id(), &fact); + if (facesel && (tmp != NULL) && (faceselreqview == 0)) tmp->deallocateBuffer(MLSelectionBuffers::ML_PERFACE_SEL); - if (facesel && vertsel) + if ((faceselreqview == 0) && (vertselreqview == 0)) { delete tmp; vcg::tri::Allocator::DeletePerMeshAttribute(mm.cm, selbufhand); @@ -619,8 +706,94 @@ void MLDefaultMeshDecorators::initNonManifEdgeDecoratorData(MeshModel& m) void MLDefaultMeshDecorators::cleanNonManifEdgeDecoratorData( MeshModel& m ) { - vcg::tri::Allocator::DeletePerMeshAttribute(m.cm,nonManifEdgeAttName()); - vcg::tri::Allocator::DeletePerMeshAttribute(m.cm,nonManifEdgeFaceAttName()); + if (_mw == NULL) + return; + + MLRenderingEdgeManifoldAction eact(m.id(), NULL); + unsigned int manifreqviews = _mw->viewsRequiringRenderingActions(m.id(), &eact); + + if (manifreqviews == 0) + { + CMeshO::PerMeshAttributeHandle< std::vector > beH; + beH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, nonManifEdgeAttName()); + if (beH._handle != NULL) + beH().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, beH); + + CMeshO::PerMeshAttributeHandle< std::vector > bef; + bef = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, nonManifEdgeFaceAttName()); + if (bef._handle != NULL) + bef().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, bef); + + } +} + +void MLDefaultMeshDecorators::initNonManifVertDecoratorData(MeshModel& mm) +{ + CMeshO::PerMeshAttributeHandle > bvH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(mm.cm, nonManifVertAttName()); + CMeshO::PerMeshAttributeHandle > fvH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(mm.cm, nonManifVertFaceAttName()); + std::vector *BVp = &bvH(); + std::vector *FVp = &fvH(); + BVp->clear(); + FVp->clear(); + mm.updateDataMask(MeshModel::MM_FACEFACETOPO); + vcg::tri::SelectionStack ss(mm.cm); + ss.push(); + vcg::tri::UpdateSelection::VertexClear(mm.cm); + int res = vcg::tri::Clean::CountNonManifoldVertexFF(mm.cm, true); + vcg::Color4b bCol(255, 0, 255, 0); + vcg::Color4b vCol(255, 0, 255, 64); + vcg::tri::UpdateFlags::VertexClearV(mm.cm); + for (CMeshO::FaceIterator fi = mm.cm.face.begin(); fi != mm.cm.face.end(); ++fi) + { + if (!(*fi).IsD()) + { + for (int i = 0; i < 3; ++i) + { + if ((*fi).V(i)->IsS()) + { + if (!(*fi).V0(i)->IsV()) + { + BVp->push_back(std::make_pair((*fi).V0(i)->P(), vcg::Color4b(vcg::Color4b::Magenta))); + (*fi).V0(i)->SetV(); + } + + Point3m P1 = ((*fi).V0(i)->P() + (*fi).V1(i)->P()) / 2.0f; + Point3m P2 = ((*fi).V0(i)->P() + (*fi).V2(i)->P()) / 2.0f; + FVp->push_back(std::make_pair((*fi).V0(i)->P(), vCol)); + FVp->push_back(std::make_pair(P1, bCol)); + FVp->push_back(std::make_pair(P2, bCol)); + } + } + } + } + ss.pop(); +} + +void MLDefaultMeshDecorators::cleanNonManifVertDecoratorData(MeshModel& m) +{ + if (_mw == NULL) + return; + + MLRenderingVertManifoldAction eact(m.id(), NULL); + unsigned int manifreqviews = _mw->viewsRequiringRenderingActions(m.id(), &eact); + + if (manifreqviews == 0) + { + CMeshO::PerMeshAttributeHandle< std::vector > beH; + beH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, nonManifVertAttName()); + if (beH._handle != NULL) + beH().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, beH); + + CMeshO::PerMeshAttributeHandle< std::vector > bef; + bef = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, nonManifVertFaceAttName()); + if (bef._handle != NULL) + bef().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, bef); + + } } void MLDefaultMeshDecorators::initBoundaryTextDecoratorData( MeshModel& m) @@ -661,7 +834,17 @@ void MLDefaultMeshDecorators::initBoundaryTextDecoratorData( MeshModel& m) void MLDefaultMeshDecorators::cleanBoundaryTextDecoratorData( MeshModel& m) { - vcg::tri::Allocator::DeletePerMeshAttribute(m.cm,boundaryTextVertAttName()); + MLRenderingTexBorderAction eact(m.id(), NULL); + unsigned int manifreqviews = _mw->viewsRequiringRenderingActions(m.id(), &eact); + + if (manifreqviews == 0) + { + CMeshO::PerMeshAttributeHandle< std::vector > beH; + beH = vcg::tri::Allocator::GetPerMeshAttribute< std::vector >(m.cm, boundaryTextVertAttName()); + if (beH._handle != NULL) + beH().clear(); + vcg::tri::Allocator::DeletePerMeshAttribute>(m.cm, beH); + } } void MLDefaultMeshDecorators::drawLineVector(std::vector &EV) diff --git a/src/meshlab/ml_default_decorators.h b/src/meshlab/ml_default_decorators.h index c15cf9c71..fc33f4fe6 100644 --- a/src/meshlab/ml_default_decorators.h +++ b/src/meshlab/ml_default_decorators.h @@ -21,14 +21,20 @@ * * ****************************************************************************/ +#ifndef ML_DEFAULT_DECORATORS_H +#define ML_DEFAULT_DECORATORS_H #include #include #include +class MainWindow; + class MLDefaultMeshDecorators { public: + MLDefaultMeshDecorators(MainWindow* mw); + typedef std::pair PointPC; // this type is used to have a simple coord+color pair to rapidly draw non manifold faces //the initMeshDecorationData is called when a mesh has been updated by a filter execution @@ -38,7 +44,21 @@ public: //The updateMeshDecorationData is called when a decoration button is clicked on/off bool updateMeshDecorationData(MeshModel& mesh,const MLRenderingData& previousdata,const MLRenderingData& currentdata); - + + static const char* selectionAttName() { return "SelectionBuffers"; } + + static const char* boundaryVertAttName() { return "BoundaryVertVector"; } + static const char* boundaryEdgeAttName() { return "BoundaryEdgeVector"; } + static const char* boundaryFaceAttName() { return "BoundaryFaceVector"; } + + static const char* nonManifEdgeAttName() { return "NonManifEdgeVector"; } + static const char* nonManifEdgeFaceAttName() { return "NonManifEdgeFaceVector"; } + + static const char* nonManifVertAttName() { return "NonManifVertVector"; } + static const char* nonManifVertFaceAttName() { return "NonManifVertFaceVector"; } + + static const char* boundaryTextVertAttName() { return "BoundaryTexVector"; } + private: void initBoundaryDecoratorData(MeshModel& mm,bool edgeboundary,bool faceboundary); void cleanBoundaryDecoratorData(MeshModel& mm,bool edgeboundary,bool faceboundary); @@ -49,22 +69,13 @@ private: void initNonManifEdgeDecoratorData(MeshModel& mm); void cleanNonManifEdgeDecoratorData(MeshModel& mm); + void initNonManifVertDecoratorData(MeshModel& mm); + void cleanNonManifVertDecoratorData(MeshModel& mm); + void initBoundaryTextDecoratorData(MeshModel& mm); void cleanBoundaryTextDecoratorData(MeshModel& mm); - static const char* selectionAttName() { return "SelectionBuffers"; } - static const char* boundaryVertAttName() {return "BoundaryVertVector";} - static const char* boundaryEdgeAttName() {return "BoundaryEdgeVector";} - static const char* boundaryFaceAttName() {return "BoundaryFaceVector";} - - static const char* nonManifEdgeAttName() {return "NonManifEdgeVector";} - static const char* nonManifEdgeFaceAttName() {return "NonManifEdgeFaceVector";} - - static const char* nonManifVertAttName() {return "NonManifVertVector";} - static const char* nonManifVertFaceAttName() {return "NonManifVertFaceVector";} - - static const char* boundaryTextVertAttName() {return "BoundaryTexVector";} static void drawLineVector(std::vector &EV); static void drawTriVector(std::vector &TV); @@ -74,4 +85,8 @@ private: static void chooseX(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &x1,vcg::Point3d &x2); static void chooseY(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &y1,vcg::Point3d &y2); static void chooseZ(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &z1,vcg::Point3d &z2); -}; \ No newline at end of file + + MainWindow* _mw; +}; + +#endif \ No newline at end of file diff --git a/src/meshlab/multiViewer_Container.h b/src/meshlab/multiViewer_Container.h index e17373beb..e5c7029e5 100644 --- a/src/meshlab/multiViewer_Container.h +++ b/src/meshlab/multiViewer_Container.h @@ -23,13 +23,15 @@ #ifndef __MULTIVIEWER_CONTAINER_H__ #define __MULTIVIEWER_CONTAINER_H__ +#include + #include +#include #include #include #include #include "../common/meshmodel.h" -#include #include "../common/ml_shared_data_context.h" // Class list @@ -82,7 +84,8 @@ public: int getNextViewerId(); int viewerCounter(); - void updateAllViewer(); + void updateAllViewer(); + void resetAllTrackBall(); void update(int id);