Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
608af682
Commit
608af682
authored
Jun 07, 2011
by
Sylvain Thery
Browse files
Remove Qt dependency in CGoGNStream.h
parent
48e27569
Changes
4
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto5.cpp
View file @
608af682
...
...
@@ -342,9 +342,9 @@ int main(int argc, char **argv)
GLint
texSize
;
glGetIntegerv
(
GL_MAX_TEXTURE_SIZE
,
&
texSize
);
CGoGNdbg
2
.
toConsole
(
&
sqt
);
CGoGNdbg
.
toConsole
(
&
sqt
);
CGoGNerr
.
toConsole
(
&
sqt
);
CGoGNdbg
2
<<
" TextureSize "
<<
texSize
<<
CGoGNendl
;
CGoGNdbg
<<
" TextureSize "
<<
texSize
<<
CGoGNendl
;
CGoGNerr
<<
" test ERROR "
<<
5
*
7
<<
CGoGNflush
;
...
...
include/Utils/cgognStream.h
View file @
608af682
...
...
@@ -83,7 +83,7 @@ enum drawingType
class
Special
{};
template
<
int
LEVEL
>
class
Out
{
protected:
...
...
@@ -142,18 +142,18 @@ public:
/**
* recursive stream operator
*/
Out
<
LEVEL
>
&
operator
<<
(
Out
&
cgstr
);
Out
&
operator
<<
(
Out
&
cgstr
);
/**
* classic stream operator
*/
template
<
typename
T
>
Out
<
LEVEL
>
&
operator
<<
(
const
T
&
val
);
Out
&
operator
<<
(
const
T
&
val
);
/**
* special cases (endl) stream operator
*/
Out
<
LEVEL
>
&
operator
<<
(
Special
&
os
);
Out
&
operator
<<
(
Special
&
os
);
/**
* for file closing
...
...
@@ -164,33 +164,43 @@ public:
/**
* output stream class for error output (replace cout by cerr)
*/
template
<
int
LEVEL
>
class
Err
:
public
Out
<
LEVEL
>
class
Err
:
public
Out
{
public:
Err
()
{
this
->
m_code
=
1
;
}
};
template
<
int
LEVEL
>
class
Dbg
:
public
Out
<
LEVEL
>
class
Dbg
:
public
Out
{
public:
Dbg
()
{
this
->
m_code
=
100
+
LEVEL
;
}
Dbg
()
{
this
->
m_code
=
100
;
}
};
template
<
typename
T
>
Out
&
Out
::
operator
<<
(
const
T
&
val
)
{
if
(
m_out_mode
&
STDOUT
)
std
::
cout
<<
val
;
if
(
m_out_mode
&
STDERR
)
std
::
cerr
<<
val
;
if
(
m_out_mode
&&
(
FILEOUT
|
QTSTATUSBAR
|
QTCONSOLE
|
SSBUFFER
))
m_buffer
<<
val
;
return
*
this
;
}
}
// namespace CGoGNStream
// glocal stream definitions
extern
CGoGNStream
::
Out
<
0
>
CGoGNout
;
extern
CGoGNStream
::
Err
<
0
>
CGoGNerr
;
extern
CGoGNStream
::
Dbg
<
1
>
CGoGNdbg
;
extern
CGoGNStream
::
Dbg
<
2
>
CGoGNdbg2
;
extern
CGoGNStream
::
Dbg
<
3
>
CGoGNdbg3
;
extern
CGoGNStream
::
Out
CGoGNout
;
extern
CGoGNStream
::
Err
CGoGNerr
;
extern
CGoGNStream
::
Dbg
CGoGNdbg
;
extern
CGoGNStream
::
Special
CGoGNendl
;
extern
CGoGNStream
::
Special
CGoGNflush
;
}
// namespace CGoGN
#include
"Utils/cgognStream.hpp"
#endif
/* CGOGNSTREAM_H_ */
include/Utils/cgognStream.hpp
deleted
100644 → 0
View file @
48e27569
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library 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 Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
"Utils/qtSimple.h"
#include
<QtGui/QTextEdit>
namespace
CGoGN
{
namespace
CGoGNStream
{
template
<
int
LEVEL
>
Out
<
LEVEL
>::
Out
()
:
m_out_mode
(
STDOUT
),
m_sqt_bar
(
NULL
),
m_sqt_console
(
NULL
),
m_qte
(
NULL
),
m_ofs
(
NULL
),
m_oss
(
NULL
),
m_code
(
0
)
{}
template
<
int
LEVEL
>
Out
<
LEVEL
>::~
Out
()
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
m_ofs
!=
NULL
)
{
m_ofs
->
close
();
delete
m_ofs
;
}
}
}
template
<
int
LEVEL
>
void
Out
<
LEVEL
>::
toStd
(
bool
yes
)
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
m_code
)
{
if
(
yes
)
this
->
m_out_mode
|=
STDERR
;
else
this
->
m_out_mode
&=
~
STDERR
;
}
else
{
if
(
yes
)
m_out_mode
|=
STDOUT
;
else
m_out_mode
&=
~
STDOUT
;
}
}
}
//template<int LEVEL>
//void Err<LEVEL>::toStd(bool yes)
//{
// if (LEVEL<=DBG_MAX_LEVEL)
// {
// if (yes)
// this->m_out_mode |= STDERR;
// else
// this->m_out_mode &= ~STDERR;
// }
//}
template
<
int
LEVEL
>
void
Out
<
LEVEL
>::
toFile
(
const
std
::
string
&
filename
)
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
!
filename
.
empty
())
m_out_mode
|=
FILEOUT
;
else
m_out_mode
&=
~
FILEOUT
;
if
(
m_ofs
!=
NULL
)
{
m_ofs
->
close
();
delete
m_ofs
;
}
m_ofs
=
new
std
::
ofstream
(
filename
.
c_str
());
}
}
template
<
int
LEVEL
>
void
Out
<
LEVEL
>::
toStatusBar
(
Utils
::
QT
::
SimpleQT
*
sqt
)
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
sqt
!=
NULL
)
m_out_mode
|=
QTSTATUSBAR
;
else
m_out_mode
&=
~
QTSTATUSBAR
;
m_sqt_bar
=
sqt
;
}
}
template
<
int
LEVEL
>
void
Out
<
LEVEL
>::
toConsole
(
Utils
::
QT
::
SimpleQT
*
sqt
)
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
sqt
)
m_out_mode
|=
QTCONSOLE
;
else
m_out_mode
&=
~
QTCONSOLE
;
m_sqt_console
=
sqt
;
}
}
template
<
int
LEVEL
>
void
Out
<
LEVEL
>::
toBuffer
(
std
::
stringstream
*
ss
)
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
ss
!=
NULL
)
m_out_mode
|=
SSBUFFER
;
else
m_out_mode
&=
~
SSBUFFER
;
m_oss
=
ss
;
}
}
template
<
int
LEVEL
>
Out
<
LEVEL
>&
Out
<
LEVEL
>::
operator
<<
(
Out
&
os
)
{
return
*
this
;
}
template
<
int
LEVEL
>
void
Out
<
LEVEL
>::
close
()
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
m_ofs
!=
NULL
)
{
m_ofs
->
close
();
}
}
}
template
<
int
LEVEL
>
template
<
typename
T
>
Out
<
LEVEL
>&
Out
<
LEVEL
>::
operator
<<
(
const
T
&
val
)
{
if
(
m_out_mode
&
STDOUT
)
std
::
cout
<<
val
;
if
(
m_out_mode
&
STDERR
)
std
::
cerr
<<
val
;
if
(
m_out_mode
&&
(
FILEOUT
|
QTSTATUSBAR
|
QTCONSOLE
|
SSBUFFER
))
m_buffer
<<
val
;
return
*
this
;
}
template
<
int
LEVEL
>
Out
<
LEVEL
>&
Out
<
LEVEL
>::
operator
<<
(
Special
&
os
)
{
if
(
LEVEL
<=
DBG_MAX_LEVEL
)
{
if
(
&
os
==
&
CGoGNendl
)
{
char
bufc
[
512
];
// for cout & cerr just do the endl
if
(
m_out_mode
&
STDOUT
)
std
::
cout
<<
std
::
endl
;;
if
(
m_out_mode
&
STDERR
)
std
::
cerr
<<
std
::
endl
;
if
(
m_out_mode
&
FILEOUT
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
*
m_ofs
<<
bufc
<<
std
::
endl
;
}
}
if
(
m_out_mode
&
QTSTATUSBAR
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
m_sqt_bar
->
statusMsg
(
bufc
);
}
}
if
(
m_out_mode
&
QTCONSOLE
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
if
(
m_code
>=
100
)
m_sqt_console
->
console
()
->
setTextColor
(
QColor
(
0
,
150
-
(
m_code
-
100
)
*
20
,
50
+
(
m_code
-
100
)
*
20
));
else
{
if
(
m_code
>
0
)
m_sqt_console
->
console
()
->
setTextColor
(
QColor
(
150
,
0
,
0
));
else
m_sqt_console
->
console
()
->
setTextColor
(
QColor
(
0
,
0
,
150
));
}
// m_sqt_console->console()->insertPlainText(QString(bufc));
// m_sqt_console->console()->insertPlainText(QString("\n"));
m_sqt_console
->
console
()
->
append
(
QString
(
bufc
));
}
}
if
(
m_out_mode
&
SSBUFFER
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
*
m_oss
<<
bufc
<<
std
::
endl
;
}
}
}
if
(
&
os
==
&
CGoGNflush
)
{
char
bufc
[
512
];
// for cout & cerr just do the endl
if
(
m_out_mode
&
STDOUT
)
std
::
cout
<<
std
::
flush
;
if
(
m_out_mode
&
STDERR
)
std
::
cerr
<<
std
::
flush
;
if
(
m_out_mode
&
FILEOUT
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
*
m_ofs
<<
bufc
<<
std
::
flush
;
}
}
if
(
m_out_mode
&
QTSTATUSBAR
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
m_sqt_bar
->
statusMsg
(
bufc
);
}
}
if
(
m_out_mode
&
QTCONSOLE
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
if
(
m_code
>=
100
)
m_sqt_console
->
console
()
->
setTextColor
(
QColor
(
0
,
150
-
(
m_code
-
100
)
*
20
,
50
+
(
m_code
-
100
)
*
20
));
else
{
if
(
m_code
>
0
)
m_sqt_console
->
console
()
->
setTextColor
(
QColor
(
150
,
0
,
0
));
else
m_sqt_console
->
console
()
->
setTextColor
(
QColor
(
0
,
0
,
150
));
}
m_sqt_console
->
console
()
->
moveCursor
(
QTextCursor
::
End
);
m_sqt_console
->
console
()
->
insertPlainText
(
QString
(
bufc
));
}
}
if
(
m_out_mode
&
SSBUFFER
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
*
m_oss
<<
bufc
<<
std
::
flush
;
}
}
}
}
m_buffer
.
clear
();
return
*
this
;
}
}
// namespace CGoGNStream
}
// namespace CGoGN
src/Utils/cgognStream.cpp
View file @
608af682
...
...
@@ -23,22 +23,15 @@
*******************************************************************************/
#include
"Utils/cgognStream.h"
#include
"Utils/qtSimple.h"
#include
<QtGui/QTextEdit>
namespace
CGoGN
{
//CGoGNStream::Out CGoGNout;
//CGoGNStream::Err CGoGNerr;
//CGoGNStream::Out CGoGNdbg;
//
//CGoGNStream::Special CGoGNendl;
CGoGNStream
::
Out
<
0
>
CGoGNout
;
CGoGNStream
::
Err
<
0
>
CGoGNerr
;
CGoGNStream
::
Dbg
<
1
>
CGoGNdbg
;
CGoGNStream
::
Dbg
<
2
>
CGoGNdbg2
;
CGoGNStream
::
Dbg
<
3
>
CGoGNdbg3
;
CGoGNStream
::
Out
CGoGNout
;
CGoGNStream
::
Err
CGoGNerr
;
CGoGNStream
::
Dbg
CGoGNdbg
;
CGoGNStream
::
Special
CGoGNendl
;
CGoGNStream
::
Special
CGoGNflush
;
...
...
@@ -50,8 +43,7 @@ void allToStd(bool yes)
CGoGNout
.
toStd
(
yes
);
CGoGNerr
.
toStd
(
yes
);
CGoGNdbg
.
toStd
(
yes
);
CGoGNdbg2
.
toStd
(
yes
);
CGoGNdbg3
.
toStd
(
yes
);
}
void
allToFile
(
const
std
::
string
&
filename
)
...
...
@@ -59,8 +51,7 @@ void allToFile(const std::string& filename )
CGoGNout
.
toFile
(
filename
);
CGoGNerr
.
toFile
(
filename
);
CGoGNdbg
.
toFile
(
filename
);
CGoGNdbg2
.
toFile
(
filename
);
CGoGNdbg3
.
toFile
(
filename
);
}
void
allToStatusBar
(
Utils
::
QT
::
SimpleQT
*
sqt
)
...
...
@@ -68,8 +59,7 @@ void allToStatusBar(Utils::QT::SimpleQT* sqt)
CGoGNout
.
toStatusBar
(
sqt
);
CGoGNerr
.
toStatusBar
(
sqt
);
CGoGNdbg
.
toStatusBar
(
sqt
);
CGoGNdbg2
.
toStatusBar
(
sqt
);
CGoGNdbg3
.
toStatusBar
(
sqt
);
}
void
allToConsole
(
Utils
::
QT
::
SimpleQT
*
sqt
)
...
...
@@ -77,8 +67,7 @@ void allToConsole(Utils::QT::SimpleQT* sqt)
CGoGNout
.
toConsole
(
sqt
);
CGoGNerr
.
toConsole
(
sqt
);
CGoGNdbg
.
toConsole
(
sqt
);
CGoGNdbg2
.
toConsole
(
sqt
);
CGoGNdbg3
.
toConsole
(
sqt
);
}
void
allToBuffer
(
std
::
stringstream
*
ss
)
...
...
@@ -86,10 +75,243 @@ void allToBuffer(std::stringstream* ss)
CGoGNout
.
toBuffer
(
ss
);
CGoGNerr
.
toBuffer
(
ss
);
CGoGNdbg
.
toBuffer
(
ss
);
CGoGNdbg2
.
toBuffer
(
ss
);
CGoGNdbg3
.
toBuffer
(
ss
);
}
Out
::
Out
()
:
m_out_mode
(
STDOUT
),
m_sqt_bar
(
NULL
),
m_sqt_console
(
NULL
),
m_qte
(
NULL
),
m_ofs
(
NULL
),
m_oss
(
NULL
),
m_code
(
0
)
{}
Out
::~
Out
()
{
if
(
m_ofs
!=
NULL
)
{
m_ofs
->
close
();
delete
m_ofs
;
}
}
void
Out
::
toStd
(
bool
yes
)
{
if
(
m_code
)
{
if
(
yes
)
this
->
m_out_mode
|=
STDERR
;
else
this
->
m_out_mode
&=
~
STDERR
;
}
else
{
if
(
yes
)
m_out_mode
|=
STDOUT
;
else
m_out_mode
&=
~
STDOUT
;
}
}
void
Out
::
toFile
(
const
std
::
string
&
filename
)
{
if
(
!
filename
.
empty
())
m_out_mode
|=
FILEOUT
;
else
m_out_mode
&=
~
FILEOUT
;
if
(
m_ofs
!=
NULL
)
{
m_ofs
->
close
();
delete
m_ofs
;
}
m_ofs
=
new
std
::
ofstream
(
filename
.
c_str
());
}
void
Out
::
toStatusBar
(
Utils
::
QT
::
SimpleQT
*
sqt
)
{
if
(
sqt
!=
NULL
)
m_out_mode
|=
QTSTATUSBAR
;
else
m_out_mode
&=
~
QTSTATUSBAR
;
m_sqt_bar
=
sqt
;
}
void
Out
::
toConsole
(
Utils
::
QT
::
SimpleQT
*
sqt
)
{
if
(
sqt
)
m_out_mode
|=
QTCONSOLE
;
else
m_out_mode
&=
~
QTCONSOLE
;
m_sqt_console
=
sqt
;
}
void
Out
::
toBuffer
(
std
::
stringstream
*
ss
)
{
if
(
ss
!=
NULL
)
m_out_mode
|=
SSBUFFER
;
else
m_out_mode
&=
~
SSBUFFER
;
m_oss
=
ss
;
}
Out
&
Out
::
operator
<<
(
Out
&
os
)
{
return
*
this
;
}
void
Out
::
close
()
{
if
(
m_ofs
!=
NULL
)
{
m_ofs
->
close
();
}
}
Out
&
Out
::
operator
<<
(
Special
&
os
)
{
if
(
&
os
==
&
CGoGNendl
)
{
char
bufc
[
512
];
// for cout & cerr just do the endl
if
(
m_out_mode
&
STDOUT
)
std
::
cout
<<
std
::
endl
;;
if
(
m_out_mode
&
STDERR
)
std
::
cerr
<<
std
::
endl
;
if
(
m_out_mode
&
FILEOUT
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
*
m_ofs
<<
bufc
<<
std
::
endl
;
}
}
if
(
m_out_mode
&
QTSTATUSBAR
)
{
while
(
!
m_buffer
.
eof
())
{
m_buffer
.
getline
(
bufc
,
512
);
// m_sqt_bar->statusMsg(bufc);
}
}
if
(
m_out_mode
&
QTCONSOLE
)
{
while
(
!