From 3ced3041a4be7ae4f6236d0ca4924d64d99c2b46 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Mon, 1 Mar 2021 17:25:35 +0100 Subject: [PATCH] log refactoring --- src/common/GLLogStream.cpp | 49 +++++++++---------- src/common/GLLogStream.h | 34 ++++++------- .../plugins/interfaces/plugin_interface.cpp | 10 ++-- .../plugins/interfaces/plugin_interface.h | 8 +-- src/common/plugins/plugin_manager.h | 4 +- src/meshlab/glarea.cpp | 2 +- src/meshlab/glarea.h | 4 +- src/meshlab/layerDialog.cpp | 48 +++++++++--------- src/meshlab/mainwindow_RunTime.cpp | 14 +++--- src/meshlab/ml_default_decorators.cpp | 8 +-- .../edit_point/connectedComponent.h | 13 ++--- 11 files changed, 97 insertions(+), 97 deletions(-) diff --git a/src/common/GLLogStream.cpp b/src/common/GLLogStream.cpp index 8267950e5..c240abcc1 100644 --- a/src/common/GLLogStream.cpp +++ b/src/common/GLLogStream.cpp @@ -28,88 +28,87 @@ #include "GLLogStream.h" using namespace std; -GLLogStream::GLLogStream() - :QObject() +GLLogStream::GLLogStream() : + QObject(), bookmark(-1) { - ClearBookmark(); } -void GLLogStream::RealTimeLog(const QString& Id, const QString &meshName, const QString& text) +void GLLogStream::realTimeLog(const QString& Id, const QString &meshName, const QString& text) { - this->RealTimeLogText.insert(Id,qMakePair(meshName,text) ); + this->realTimeLogText.insert(Id,qMakePair(meshName,text) ); } -void GLLogStream::Save(int /*Level*/, const char * filename ) +void GLLogStream::save(int /*Level*/, const char * filename ) { FILE *fp=fopen(filename,"wb"); QList > ::iterator li; - for(li=S.begin();li!=S.end();++li) + for(li=logTextList.begin();li!=logTextList.end();++li) fprintf(fp,"%s", qUtf8Printable((*li).second)); } -void GLLogStream::ClearBookmark() +void GLLogStream::clearBookmark() { bookmark = -1; } -void GLLogStream::SetBookmark() +void GLLogStream::setBookmark() { - bookmark=S.size(); + bookmark=logTextList.size(); } -void GLLogStream::BackToBookmark() +void GLLogStream::backToBookmark() { if(bookmark<0) return; - while(S.size() > bookmark ) - S.removeLast(); + while(logTextList.size() > bookmark ) + logTextList.removeLast(); } const QList >& GLLogStream::logStringList() const { - return S; + return logTextList; } const QMultiMap >& GLLogStream::realTimeLogMultiMap() const { - return RealTimeLogText; + return realTimeLogText; } void GLLogStream::clearRealTimeLog() { - RealTimeLogText.clear(); + realTimeLogText.clear(); } void GLLogStream::print(QStringList &out) const { out.clear(); - for (const pair & p : S) + for (const pair & p : logTextList) out.push_back(p.second); } -void GLLogStream::Clear() +void GLLogStream::clear() { - S.clear(); + logTextList.clear(); } -void GLLogStream::Log(int Level, const char * buf ) +void GLLogStream::log(int Level, const char * buf ) { QString tmp(buf); - S.push_back(std::make_pair(Level,tmp)); + logTextList.push_back(std::make_pair(Level,tmp)); qDebug("LOG: %i %s",Level,buf); emit logUpdated(); } -void GLLogStream::Log(int Level, const string& logMessage) +void GLLogStream::log(int Level, const string& logMessage) { - S.push_back(std::make_pair(Level, QString::fromStdString(logMessage))); + logTextList.push_back(std::make_pair(Level, QString::fromStdString(logMessage))); qDebug("LOG: %i %s",Level, logMessage.c_str()); emit logUpdated(); } -void GLLogStream::Log(int Level, const QString& logMessage) +void GLLogStream::log(int Level, const QString& logMessage) { - S.push_back(std::make_pair(Level, logMessage)); + logTextList.push_back(std::make_pair(Level, logMessage)); qDebug("LOG: %i %s",Level, logMessage.toStdString().c_str()); emit logUpdated(); } diff --git a/src/common/GLLogStream.h b/src/common/GLLogStream.h index 5cfc03345..fea4e62c7 100644 --- a/src/common/GLLogStream.h +++ b/src/common/GLLogStream.h @@ -52,56 +52,56 @@ public: GLLogStream(); ~GLLogStream() {} void print(QStringList &list) const; // Fills a QStringList with the log entries - void Save(int Level, const char *filename); - void Clear(); + void save(int Level, const char *filename); + void clear(); template - void Logf(int Level, const char * f, Ts&&... ts ) + void logf(int Level, const char * f, Ts&&... ts ) { char buf[buf_size]; int chars_written = snprintf(buf, buf_size, f, std::forward(ts)...); - Log(Level, buf); + log(Level, buf); if(chars_written >= static_cast(buf_size)){ - Log(Level, "Log message truncated."); + log(Level, "Log message truncated."); } } - void Log(int Level, const char * buf); - void Log(int Level, const std::string& logMessage); - void Log(int Level, const QString& logMessage); - void SetBookmark(); - void ClearBookmark(); - void BackToBookmark(); + void log(int Level, const char * buf); + void log(int Level, const std::string& logMessage); + void log(int Level, const QString& logMessage); + void setBookmark(); + void clearBookmark(); + void backToBookmark(); const QList >& logStringList() const; const QMultiMap >& realTimeLogMultiMap() const; void clearRealTimeLog(); template - void RealTimeLogf(const QString& Id, const QString &meshName, const char * f, Ts&&... ts ) + void realTimeLogf(const QString& Id, const QString &meshName, const char * f, Ts&&... ts ) { char buf[buf_size]; int chars_written = snprintf(buf, buf_size, f, std::forward(ts)...); - RealTimeLog(Id, meshName, buf); + realTimeLog(Id, meshName, buf); if(chars_written >= static_cast(buf_size)){ - RealTimeLog(Id, meshName, "Log message truncated."); + realTimeLog(Id, meshName, "Log message truncated."); } } - void RealTimeLog(const QString& Id, const QString &meshName, const QString& text); + void realTimeLog(const QString& Id, const QString &meshName, const QString& text); signals: void logUpdated(); private: int bookmark; /// this field is used to place a bookmark for restoring the log. Useful for previeweing - QList > S; + QList > logTextList; // The list of strings used in realtime display of info over the mesh. // Each box is identified by the title, name of the mesh and text. // the name of the mesh is shown only if two or more box with the same title are shown. - QMultiMap > RealTimeLogText; + QMultiMap > realTimeLogText; }; #endif //GLLOGSTREAM_H diff --git a/src/common/plugins/interfaces/plugin_interface.cpp b/src/common/plugins/interfaces/plugin_interface.cpp index 7161c8049..f036aa1e1 100644 --- a/src/common/plugins/interfaces/plugin_interface.cpp +++ b/src/common/plugins/interfaces/plugin_interface.cpp @@ -13,34 +13,34 @@ void PluginInterface::setLog(GLLogStream* log) void PluginInterface::log(const char* s) { if(logstream != nullptr) { - logstream->Log(GLLogStream::FILTER, s); + logstream->log(GLLogStream::FILTER, s); } } void PluginInterface::log(const std::string& s) { if(logstream != nullptr) { - logstream->Log(GLLogStream::FILTER, s); + logstream->log(GLLogStream::FILTER, s); } } void PluginInterface::log(GLLogStream::Levels level, const char* s) { if(logstream != nullptr) { - logstream->Log(level, s); + logstream->log(level, s); } } void PluginInterface::log(GLLogStream::Levels level, const std::string& s) { if(logstream != nullptr) { - logstream->Log(level, s); + logstream->log(level, s); } } void PluginInterface::realTimeLog(QString Id, const QString& meshName, const char* f) { if(logstream != nullptr) { - logstream->RealTimeLog(Id, meshName, f); + logstream->realTimeLog(Id, meshName, f); } } diff --git a/src/common/plugins/interfaces/plugin_interface.h b/src/common/plugins/interfaces/plugin_interface.h index 96d07e912..f89e13e2a 100644 --- a/src/common/plugins/interfaces/plugin_interface.h +++ b/src/common/plugins/interfaces/plugin_interface.h @@ -91,7 +91,7 @@ template void PluginInterface::log(const char* f, Ts&&... ts) { if(logstream != nullptr) { - logstream->Logf(GLLogStream::FILTER, f, std::forward(ts)...); + logstream->logf(GLLogStream::FILTER, f, std::forward(ts)...); } } @@ -99,7 +99,7 @@ template void PluginInterface::log(const std::string& s, Ts&&... ts) { if(logstream != nullptr) { - logstream->Logf(GLLogStream::FILTER, s.c_str(), std::forward(ts)...); + logstream->logf(GLLogStream::FILTER, s.c_str(), std::forward(ts)...); } } @@ -107,7 +107,7 @@ template void PluginInterface::log(GLLogStream::Levels Level, const char* f, Ts&&... ts) { if(logstream != nullptr) { - logstream->Logf(Level, f, std::forward(ts)...); + logstream->logf(Level, f, std::forward(ts)...); } } @@ -115,7 +115,7 @@ template void PluginInterface::realTimeLog(QString Id, const QString& meshName, const char* f, Ts&&... ts) { if(logstream != nullptr) { - logstream->RealTimeLogf(Id, meshName, f, std::forward(ts)...); + logstream->realTimeLogf(Id, meshName, f, std::forward(ts)...); } } diff --git a/src/common/plugins/plugin_manager.h b/src/common/plugins/plugin_manager.h index be1a9872a..f79de05b7 100644 --- a/src/common/plugins/plugin_manager.h +++ b/src/common/plugins/plugin_manager.h @@ -36,8 +36,8 @@ #include /** -\brief This class provides the basic tools for managing all the plugins. It is used by both meshlab and meshlab server. -*/ + * @brief The PluginManager class provides the basic tools for managing all the plugins. + */ class PluginManager { public: diff --git a/src/meshlab/glarea.cpp b/src/meshlab/glarea.cpp index b7adde78e..f75aea81a 100644 --- a/src/meshlab/glarea.cpp +++ b/src/meshlab/glarea.cpp @@ -947,7 +947,7 @@ void GLArea::displayHelp() tableText.replace("Ctrl","Command"); #endif } - md()->Log.RealTimeLog("Quick Help","",tableText); + md()->Log.realTimeLog("Quick Help","",tableText); } diff --git a/src/meshlab/glarea.h b/src/meshlab/glarea.h index ac32a5bef..6c490ae14 100644 --- a/src/meshlab/glarea.h +++ b/src/meshlab/glarea.h @@ -138,7 +138,7 @@ public: { makeCurrent(); if( this->md() != nullptr){ - this->md()->Log.Logf(Level, f, std::forward(ts)...); + this->md()->Log.logf(Level, f, std::forward(ts)...); } } @@ -146,7 +146,7 @@ public: { makeCurrent(); if( this->md() != nullptr){ - this->md()->Log.Log(Level, f); + this->md()->Log.log(Level, f); } } diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index 1cc3b7931..fbd235edc 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -144,17 +144,17 @@ void LayerDialog::clickW1() viewState[0] = mw->GLA()->viewToText(); isRecording = false; ui->bW1->setText(QChar(0x2460)); - mw->meshDoc()->Log.Log(0, "Stored View #1"); + 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"); + mw->meshDoc()->Log.log(0, "Restored View #1"); } else - mw->meshDoc()->Log.Log(0, "No View to Restore"); + mw->meshDoc()->Log.log(0, "No View to Restore"); } void LayerDialog::clickW2() @@ -164,17 +164,17 @@ void LayerDialog::clickW2() viewState[1] = mw->GLA()->viewToText(); isRecording = false; ui->bW2->setText(QChar(0x2461)); - mw->meshDoc()->Log.Log(0, "Stored View #2"); + mw->meshDoc()->Log.log(0, "Stored View #2"); } else if (viewState[1] != "") { QDomDocument doc("StringDoc"); doc.setContent(viewState[1]); mw->GLA()->loadViewFromViewStateFile(doc); - mw->meshDoc()->Log.Log(0, "Restored View #2"); + mw->meshDoc()->Log.log(0, "Restored View #2"); } else - mw->meshDoc()->Log.Log(0, "No View to Restore"); + mw->meshDoc()->Log.log(0, "No View to Restore"); } void LayerDialog::clickW3() @@ -184,17 +184,17 @@ void LayerDialog::clickW3() viewState[2] = mw->GLA()->viewToText(); isRecording = false; ui->bW3->setText(QChar(0x2462)); - mw->meshDoc()->Log.Log(0, "Stored View #3"); + mw->meshDoc()->Log.log(0, "Stored View #3"); } else if (viewState[2] != "") { QDomDocument doc("StringDoc"); doc.setContent(viewState[2]); mw->GLA()->loadViewFromViewStateFile(doc); - mw->meshDoc()->Log.Log(0, "Restored View #3"); + mw->meshDoc()->Log.log(0, "Restored View #3"); } else - mw->meshDoc()->Log.Log(0, "No View to Restore"); + mw->meshDoc()->Log.log(0, "No View to Restore"); } void LayerDialog::clickW4() @@ -204,17 +204,17 @@ void LayerDialog::clickW4() viewState[3] = mw->GLA()->viewToText(); isRecording = false; ui->bW4->setText(QChar(0x2463)); - mw->meshDoc()->Log.Log(0, "Stored View #4"); + mw->meshDoc()->Log.log(0, "Stored View #4"); } else if (viewState[3] != "") { QDomDocument doc("StringDoc"); doc.setContent(viewState[3]); mw->GLA()->loadViewFromViewStateFile(doc); - mw->meshDoc()->Log.Log(0, "Restored View #4"); + mw->meshDoc()->Log.log(0, "Restored View #4"); } else - mw->meshDoc()->Log.Log(0, "No View to Restore"); + mw->meshDoc()->Log.log(0, "No View to Restore"); } void LayerDialog::clickV1() @@ -229,7 +229,7 @@ void LayerDialog::clickV1() } isRecording = false; ui->bV1->setText(QChar(0x2460)); - mw->meshDoc()->Log.Log(0, "Stored Visibility #1"); + mw->meshDoc()->Log.log(0, "Stored Visibility #1"); } else if (!visibilityState[0].isEmpty()) { @@ -242,10 +242,10 @@ void LayerDialog::clickV1() updatePerMeshItemVisibility(); updatePerMeshItemSelectionStatus(); mw->GLA()->update(); - mw->meshDoc()->Log.Log(0, "Restored Visibility #1"); + mw->meshDoc()->Log.log(0, "Restored Visibility #1"); } else - mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); + mw->meshDoc()->Log.log(0, "No Visibility to Restore"); } void LayerDialog::clickV2() { @@ -259,7 +259,7 @@ void LayerDialog::clickV2() } isRecording = false; ui->bV2->setText(QChar(0x2461)); - mw->meshDoc()->Log.Log(0, "Stored Visibility #2"); + mw->meshDoc()->Log.log(0, "Stored Visibility #2"); } else if (!visibilityState[1].isEmpty()) { @@ -272,10 +272,10 @@ void LayerDialog::clickV2() updatePerMeshItemVisibility(); updatePerMeshItemSelectionStatus(); mw->GLA()->update(); - mw->meshDoc()->Log.Log(0, "Restored Visibility #2"); + mw->meshDoc()->Log.log(0, "Restored Visibility #2"); } else - mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); + mw->meshDoc()->Log.log(0, "No Visibility to Restore"); } void LayerDialog::clickV3() { @@ -289,7 +289,7 @@ void LayerDialog::clickV3() } isRecording = false; ui->bV3->setText(QChar(0x2462)); - mw->meshDoc()->Log.Log(0, "Stored Visibility #3"); + mw->meshDoc()->Log.log(0, "Stored Visibility #3"); } else if (!visibilityState[2].isEmpty()) { @@ -302,10 +302,10 @@ void LayerDialog::clickV3() updatePerMeshItemVisibility(); updatePerMeshItemSelectionStatus(); mw->GLA()->update(); - mw->meshDoc()->Log.Log(0, "Restored Visibility #3"); + mw->meshDoc()->Log.log(0, "Restored Visibility #3"); } else - mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); + mw->meshDoc()->Log.log(0, "No Visibility to Restore"); } void LayerDialog::clickV4() { @@ -319,7 +319,7 @@ void LayerDialog::clickV4() } isRecording = false; ui->bV4->setText(QChar(0x2463)); - mw->meshDoc()->Log.Log(0, "Stored Visibility #4"); + mw->meshDoc()->Log.log(0, "Stored Visibility #4"); } else if (!visibilityState[3].isEmpty()) { @@ -332,10 +332,10 @@ void LayerDialog::clickV4() updatePerMeshItemVisibility(); updatePerMeshItemSelectionStatus(); mw->GLA()->update(); - mw->meshDoc()->Log.Log(0, "Restored Visibility #4"); + mw->meshDoc()->Log.log(0, "Restored Visibility #4"); } else - mw->meshDoc()->Log.Log(0, "No Visibility to Restore"); + mw->meshDoc()->Log.log(0, "No Visibility to Restore"); } void LayerDialog::enterEvent(QEvent* /*event*/) diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 13a26f8a2..1ccabc4f6 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -961,7 +961,7 @@ void MainWindow::startFilter() if(currentViewContainer()) { iFilter->setLog(currentViewContainer()->LogPtr()); - currentViewContainer()->LogPtr()->SetBookmark(); + currentViewContainer()->LogPtr()->setBookmark(); } // just to be sure... createStdPluginWnd(); @@ -1159,9 +1159,9 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms, // (3) save the current filter and its parameters in the history if(!isPreview) - meshDoc()->Log.ClearBookmark(); + meshDoc()->Log.clearBookmark(); else - meshDoc()->Log.BackToBookmark(); + meshDoc()->Log.backToBookmark(); // (4) Apply the Filter bool ret; qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -1236,7 +1236,7 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms, if(ret) { - meshDoc()->Log.Logf(GLLogStream::SYSTEM,"Applied filter %s in %i msec",qUtf8Printable(action->text()),tt.elapsed()); + meshDoc()->Log.logf(GLLogStream::SYSTEM,"Applied filter %s in %i msec",qUtf8Printable(action->text()),tt.elapsed()); if (meshDoc()->mm() != NULL) meshDoc()->mm()->setMeshModified(); MainWindow::globalStatusBar()->showMessage("Filter successfully completed...",2000); @@ -1250,7 +1250,7 @@ void MainWindow::executeFilter(const QAction* action, RichParameterList ¶ms, else // filter has failed. show the message error. { QMessageBox::warning(this, tr("Filter Failure"), QString("Failure of filter : '%1'

").arg(action->text())+iFilter->errorMsg()); // text - meshDoc()->Log.Logf(GLLogStream::SYSTEM,"Filter failed: %s",qUtf8Printable(iFilter->errorMsg())); + meshDoc()->Log.logf(GLLogStream::SYSTEM,"Filter failed: %s",qUtf8Printable(iFilter->errorMsg())); MainWindow::globalStatusBar()->showMessage("Filter failed...",2000); } @@ -2886,7 +2886,7 @@ void MainWindow::updateTexture(int meshid) if(!res) { QString errmsg = QString("Failure of loading texture %1").arg(fi.fileName()); - meshDoc()->Log.Log(GLLogStream::WARNING,qUtf8Printable(errmsg)); + meshDoc()->Log.log(GLLogStream::WARNING,qUtf8Printable(errmsg)); unexistingtext += "" + filename + "
"; } } @@ -3149,7 +3149,7 @@ void MainWindow::addRenderingSystemLogInfo(unsigned mmid) QString data = QString(deb._currentlyallocated.c_str()) + "\n" + QString(deb._tobedeallocated.c_str()) + "\n" + QString(deb._tobeallocated.c_str()) + "\n" + QString(deb._tobeupdated.c_str()) + "\n"; for(std::vector::iterator it = deb._perviewdata.begin();it != deb._perviewdata.end();++it) data += QString((*it).c_str()) + "
"; - meshDoc()->Log.Log(GLLogStream::SYSTEM, data); + meshDoc()->Log.log(GLLogStream::SYSTEM, data); } } } diff --git a/src/meshlab/ml_default_decorators.cpp b/src/meshlab/ml_default_decorators.cpp index 84e7c7b5e..a06d11207 100644 --- a/src/meshlab/ml_default_decorators.cpp +++ b/src/meshlab/ml_default_decorators.cpp @@ -151,7 +151,7 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData& inf += "" + QString::number(bvH().size()) + " vertex"; else inf += "" + QString::number(beH().size()/2) + " edges"; - log.RealTimeLog("Boundary",m.shortName(),inf); + log.realTimeLog("Boundary",m.shortName(),inf); } if (opts._peredge_faceboundary_enabled) @@ -161,7 +161,7 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData& inf += "" + QString::number(bvH().size()) + " vertex"; else inf += "" + QString::number(bfH().size()/3) + " faces"; - log.RealTimeLog("Boundary Faces",m.shortName(),inf); + log.realTimeLog("Boundary Faces",m.shortName(),inf); } } @@ -175,7 +175,7 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData& QString inf; 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); + log.realTimeLog("Non Manifold Vertices",m.shortName(),inf); } if (opts._peredge_edgemanifold_enabled) @@ -187,7 +187,7 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData& drawTriVector(m.cm.Tr, fvH()); QString inf; inf += "" + QString::number(bvH().size()/2) + " non manifold edges
" + QString::number(fvH().size()/3) + " faces over non manifold edges"; - log.RealTimeLog("Non Manifold Edges",m.shortName(),inf); + log.realTimeLog("Non Manifold Edges",m.shortName(),inf); } if (opts._peredge_text_boundary_enabled) diff --git a/src/meshlabplugins/edit_point/connectedComponent.h b/src/meshlabplugins/edit_point/connectedComponent.h index 5a9619a13..e74687dc2 100644 --- a/src/meshlabplugins/edit_point/connectedComponent.h +++ b/src/meshlabplugins/edit_point/connectedComponent.h @@ -173,13 +173,14 @@ static void Dijkstra(_MyMeshType& m, VertexType& v, int numOfNeighbours, float m static void DeletePerVertexAttribute(_MyMeshType& m) { - KNNGraph<_MyMeshType>::DeleteKNNTree(m); + KNNGraph<_MyMeshType>::DeleteKNNTree(m); - bool hasDistParam = tri::HasPerVertexAttribute(m, "DistParam"); - if (hasDistParam) { - Allocator<_MyMeshType>::DeletePerVertexAttribute(m, "DistParam"); - } - return; + //keeping the DistParam attribute, it could be useful to other plugins + //bool hasDistParam = tri::HasPerVertexAttribute(m, "DistParam"); + //if (hasDistParam) { + // Allocator<_MyMeshType>::DeletePerVertexAttribute(m, "DistParam"); + //} + return; } }; // end ComponentFinder Class