diff --git a/src/meshlab/GLLogStream.cpp b/src/meshlab/GLLogStream.cpp new file mode 100644 index 000000000..ffd7b719b --- /dev/null +++ b/src/meshlab/GLLogStream.cpp @@ -0,0 +1,40 @@ + +#include +#include + +#include "GLLogStream.h" + +using namespace std; +void GLLogStream::Log(int Level, const char * f, ... ) +{ + char buf[4096]; + va_list marker; + va_start( marker, f ); + + vsprintf(buf,f,marker); + va_end( marker ); + + S.push_back(make_pair(Level,buf)); +} + +void GLLogStream::Save(int Level, const char * filename ) +{ + FILE *fp=fopen(filename,"wb"); + list > ::iterator li; + for(li=S.begin();li!=S.end();++li) + fprintf(fp,(*li).second.c_str()); +} + + +void GLLogStream::glDraw(QGLWidget *qgl, int Level, int nlines) +{ + static QFont qf("Helvetica",8); + const int LineWidth=15; + list > ::iterator li; + li=S.end(); + advance(li,-nlines); + if(li==S.end()) li=S.begin(); + int StartLine=qgl->height() - (nlines+1) * LineWidth; + for(;li!=S.end();++li) + qgl->renderText(20,StartLine+=LineWidth,(*li).second.c_str(),qf); +} diff --git a/src/meshlab/GLLogStream.h b/src/meshlab/GLLogStream.h new file mode 100644 index 000000000..a066f95b5 --- /dev/null +++ b/src/meshlab/GLLogStream.h @@ -0,0 +1,68 @@ +/**************************************************************************** +* VCGLib o o * +* Visual and Computer Graphics Library o o * +* _ O _ * +* Copyright(C) 2004 +\/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +/**************************************************************************** + History +$Log$ +Revision 1.1 2005/11/16 23:19:22 cignoni +Initial Draft release; still to be adapted to our needs. + +Revision 1.1 2005/04/01 15:43:42 fiorin +Initial commit + +Revision 1.2 2005/03/18 13:45:32 fiorin +*** empty log message *** + +Revision 1.1 2005/03/15 20:26:43 fiorin +*** empty log message *** + +Revision 1.2 2005/02/22 16:28:48 fiorin +*** empty log message *** + +Revision 1.1 2004/07/12 14:02:14 cignoni +Initial Commit + + +****************************************************************************/ + +#ifndef GLLOGSTREAM_H +#define GLLOGSTREAM_H + +#include +#include +#include +#include "LogStream.h" + +class GLLogStream : public LogStream +{ +public: + void glDraw(QGLWidget *qgl, int Level, int nlines); + void Save(int Level, const char *filename); + void Clear() {S.clear();} + void Log(int Level, const char * f, ... ); + +private: + std::list > S; +}; + +#endif //GLLOGSTREAM_H diff --git a/src/meshlab/LogStream.h b/src/meshlab/LogStream.h new file mode 100644 index 000000000..c12600999 --- /dev/null +++ b/src/meshlab/LogStream.h @@ -0,0 +1,81 @@ +/**************************************************************************** +* VCGLib o o * +* Visual and Computer Graphics Library o o * +* _ O _ * +* Copyright(C) 2004 \/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +/**************************************************************************** + History +$Log$ +Revision 1.1 2005/11/16 23:19:22 cignoni +Initial Draft release; still to be adapted to our needs. + +Revision 1.2 2005/07/22 11:16:25 fiorin +out-of-core +volume partition + +Revision 1.1 2005/04/01 15:43:42 fiorin +Initial commit + +Revision 1.7 2005/03/31 12:03:04 fiorin +*** empty log message *** + +Revision 1.6 2005/03/18 13:45:32 fiorin +*** empty log message *** + +Revision 1.5 2005/03/16 22:36:45 fiorin +*** empty log message *** + +Revision 1.4 2005/03/16 17:19:24 fiorin +*** empty log message *** + +Revision 1.3 2005/03/15 20:23:02 fiorin +*** empty log message *** + +Revision 1.2 2005/02/22 16:28:48 fiorin +*** empty log message *** + +Revision 1.1 2004/07/12 14:02:14 cignoni +Initial Commit + + +****************************************************************************/ + +#ifndef LOGSTREAM_H +#define LOGSTREAM_H + +#ifdef _WINDOWS +#include +#include +#endif //_WINDOWS + + +class LogStream +{ +public: + typedef enum {Error=0, Warning=1, Info=2, Debug=3, Direct=4, OnlyFileLog=5, OnlyConsole=6} Level ; + + virtual void Log(int Level, const char * f, ... ) = 0; + +#ifdef _WINDOWS + virtual void glDraw(QGLWidget *qgl, int Level, int nlines) = 0; +#endif +}; + +#endif