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
Education
Kalzium
Commits
6fa45408
Commit
6fa45408
authored
Jan 05, 2022
by
Laurent Montel
Browse files
Use more debug categories
parent
14b42195
Pipeline
#118885
passed with stage
in 1 minute
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
libscience/CMakeLists.txt
View file @
6fa45408
add_subdirectory
(
data
)
add_subdirectory
(
tests
)
set
(
science_LIB_SRCS
add_library
(
science SHARED
)
ecm_qt_declare_logging_category
(
science HEADER kalzium_libscience_debug.h IDENTIFIER KALZIUM_LIBSCIENCE_LOG CATEGORY_NAME org.kde.kalzium.libscience DESCRIPTION
"Kalzium (libscience)"
EXPORT KALZIUM
)
target_sources
(
science PRIVATE
element.cpp
spectrum.cpp
isotope.cpp
...
...
@@ -14,7 +17,7 @@ set(science_LIB_SRCS
psetables.cpp
)
add_library
(
science SHARED
${
science_LIB_SRCS
}
)
target_link_libraries
(
science Qt5::Xml KF5::UnitConversion KF5::WidgetsAddons KF5::I18n
)
set_target_properties
(
science PROPERTIES VERSION
${
KALZIUMLIB_VERSION
}
SOVERSION
${
KALZIUMLIB_SOVERSION
}
)
...
...
libscience/chemicaldataobject.cpp
View file @
6fa45408
...
...
@@ -6,7 +6,7 @@
#include
"chemicaldataobject.h"
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
#include
<QLatin1String>
#include
<KUnitConversion/Converter>
...
...
libscience/element.cpp
View file @
6fa45408
...
...
@@ -6,7 +6,7 @@
#include
"element.h"
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
#include
<KUnitConversion/Converter>
...
...
libscience/elementparser.cpp
View file @
6fa45408
...
...
@@ -8,7 +8,7 @@
#include
"chemicaldataobject.h"
#include
"element.h"
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
#include
<KLocalizedString>
#include
<KUnitConversion/Converter>
...
...
@@ -109,9 +109,9 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co
}
else
if
((
d
->
inElement
&&
localName
==
QLatin1String
(
"scalar"
))
||
localName
==
QLatin1String
(
"array"
))
{
for
(
int
i
=
0
;
i
<
attrs
.
length
();
++
i
)
{
if
(
attrs
.
localName
(
i
)
==
QLatin1String
(
"units"
))
{
// qDebug() << "value of the unit: " << attrs.value(i);
// q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "value of the unit: " << attrs.value(i);
d
->
currentUnit
=
unit
(
attrs
.
value
(
i
));
// qDebug() << "Took " << d->currentUnit;
// q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "Took " << d->currentUnit;
continue
;
}
...
...
libscience/isotope.cpp
View file @
6fa45408
...
...
@@ -8,7 +8,7 @@
#include
"chemicaldataobject.h"
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
Isotope
::
Isotope
()
{
...
...
libscience/isotopeparser.cpp
View file @
6fa45408
...
...
@@ -8,7 +8,7 @@
#include
"chemicaldataobject.h"
#include
"isotope.h"
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
#include
<KUnitConversion/Converter>
...
...
libscience/moleculeparser.cpp
View file @
6fa45408
...
...
@@ -7,7 +7,7 @@
#include
<ctype.h>
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
#include
<QFile>
#include
<QStandardPaths>
...
...
@@ -118,9 +118,9 @@ bool MoleculeParser::weight(const QString &_shortMoleculeString,
// Expand the molecule string
// Example : MeOH -> (CH3)OH
qDebug
()
<<
_shortMoleculeString
<<
"is going to be expanded"
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
_shortMoleculeString
<<
"is going to be expanded"
;
_moleculeString
=
expandFormula
(
_shortMoleculeString
);
qDebug
()
<<
_moleculeString
<<
"is the expanded string"
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
_moleculeString
<<
"is the expanded string"
;
// Now set the expanded string
// Initialize the parsing process, and parse te molecule.
...
...
@@ -158,7 +158,7 @@ bool MoleculeParser::parseSubmolecule(double *_resultMass,
*
_resultMass
=
0.0
;
_resultMap
->
clear
();
while
(
parseTerm
(
&
subMass
,
&
subMap
))
{
//qDebug() << "Parsed a term, weight = " << subresult;
//q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "Parsed a term, weight = " << subresult;
// Add the mass and composition of the submolecule to the total.
*
_resultMass
+=
subMass
;
...
...
@@ -186,7 +186,7 @@ bool MoleculeParser::parseTerm(double *_resultMass,
_resultMap
->
clear
();
if
(
nextToken
()
==
ELEMENT_TOKEN
)
{
//qDebug() << "Parsed an element: " << m_elementVal->symbol();
//q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "Parsed an element: " << m_elementVal->symbol();
*
_resultMass
=
m_elementVal
->
dataAsVariant
(
ChemicalDataObject
::
mass
).
toDouble
();
_resultMap
->
add
(
m_elementVal
,
1
);
...
...
@@ -199,7 +199,7 @@ bool MoleculeParser::parseTerm(double *_resultMass,
// Must end in a ")".
if
(
nextToken
()
==
')'
)
{
//qDebug() << "Parsed a submolecule. weight = " << *_result;
//q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "Parsed a submolecule. weight = " << *_result;
getNextToken
();
}
else
{
return
false
;
...
...
@@ -211,7 +211,7 @@ bool MoleculeParser::parseTerm(double *_resultMass,
// Optional number.
if
(
nextToken
()
==
INT_TOKEN
)
{
//qDebug() << "Parsed a number: " << intVal();
//q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "Parsed a number: " << intVal();
*
_resultMass
*=
intVal
();
_resultMap
->
multiply
(
intVal
());
...
...
@@ -219,7 +219,7 @@ bool MoleculeParser::parseTerm(double *_resultMass,
getNextToken
();
}
qDebug
()
<<
"Weight of term = "
<<
*
_resultMass
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
"Weight of term = "
<<
*
_resultMass
;
return
true
;
}
...
...
@@ -233,7 +233,7 @@ int MoleculeParser::getNextToken()
QString
name
;
#if 0
qDebug() << "getNextToken(): Next character = "
q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "getNextToken(): Next character = "
<< nextChar() << endl;
#endif
...
...
@@ -266,11 +266,11 @@ int MoleculeParser::getNextToken()
Element
*
MoleculeParser
::
lookupElement
(
const
QString
&
_name
)
{
qDebug
()
<<
"looking up "
<<
_name
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
"looking up "
<<
_name
;
foreach
(
Element
*
e
,
m_elementList
)
{
if
(
e
->
dataAsVariant
(
ChemicalDataObject
::
symbol
)
==
_name
)
{
qDebug
()
<<
"Found element "
<<
_name
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
"Found element "
<<
_name
;
return
e
;
}
}
...
...
@@ -278,7 +278,7 @@ Element *MoleculeParser::lookupElement(const QString& _name)
//if there is an error make m_error true.
m_error
=
true
;
qDebug
()
<<
"no such element!: "
<<
_name
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
"no such element!: "
<<
_name
;
return
nullptr
;
}
...
...
@@ -310,7 +310,7 @@ QString MoleculeParser::expandFormula( const QString& _shortString)
_fullString
+=
temp
;
}
else
if
(
!
((
expandedTerm
=
expandTerm
(
temp
)).
isEmpty
()))
{
// If an expansion was made, return the expansion
qDebug
()
<<
"expanded"
<<
temp
<<
"to"
<<
expandedTerm
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
"expanded"
<<
temp
<<
"to"
<<
expandedTerm
;
_fullString
+=
'('
+
expandedTerm
+
')'
;
}
else
{
// invalid term, append it. (Validation is done later anyway.)
_fullString
+=
temp
;
...
...
@@ -347,7 +347,7 @@ QString MoleculeParser::expandFormula( const QString& _shortString)
}
else
{
// invalid character, return it, validation is done again later
_fullString
+=
*
i
;
++
i
;
qDebug
()
<<
*
i
<<
"invalid character!"
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
*
i
<<
"invalid character!"
;
}
}
...
...
@@ -368,7 +368,7 @@ QString MoleculeParser::expandTerm (const QString& _group)
// Check file validity
if
(
!
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
)))
{
qDebug
()
<<
fileName
<<
" opened"
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
fileName
<<
" opened"
;
QTextStream
in
(
&
file
);
// Get all shortForms and fullForms in the file.
...
...
@@ -386,7 +386,7 @@ QString MoleculeParser::expandTerm (const QString& _group)
}
}
}
else
{
qDebug
()
<<
fileName
<<
" could not be opened!"
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
fileName
<<
" could not be opened!"
;
}
// Find the system defined aliases
...
...
@@ -396,7 +396,7 @@ QString MoleculeParser::expandTerm (const QString& _group)
// Check file validity
if
(
!
(
!
file2
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
)))
{
qDebug
()
<<
fileName
<<
" opened"
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
fileName
<<
" opened"
;
QTextStream
in
(
&
file2
);
// Get all shortForms and fullForms in the file.
...
...
@@ -413,7 +413,7 @@ QString MoleculeParser::expandTerm (const QString& _group)
}
}
}
else
{
qDebug
()
<<
fileName
<<
" could not be opened!"
;
q
C
Debug
(
KALZIUM_LIBSCIENCE_LOG
)
<<
fileName
<<
" could not be opened!"
;
}
// Sample expansions, work even when file is not found, testing purposes
...
...
libscience/parser.cpp
View file @
6fa45408
...
...
@@ -7,7 +7,7 @@
#include
<ctype.h>
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
Parser
::
Parser
()
...
...
@@ -125,8 +125,8 @@ bool Parser::parseSimpleFloat(double *_result)
int
Parser
::
getNextChar
()
{
// qDebug() << "Parser::getNextChar(): char = " << m_nextChar;
// qDebug() << "m_str.size() " << m_str.size() << " with m_str: " << m_str << " and m_index: " << m_index;
// q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "Parser::getNextChar(): char = " << m_nextChar;
// q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "m_str.size() " << m_str.size() << " with m_str: " << m_str << " and m_index: " << m_index;
++
m_index
;
...
...
libscience/psetables.cpp
View file @
6fa45408
...
...
@@ -8,7 +8,7 @@
#include
"psetables.h"
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
#include
<KLocalizedString>
...
...
libscience/spectrumparser.cpp
View file @
6fa45408
...
...
@@ -7,7 +7,7 @@
#include
"spectrum.h"
#include
<QD
ebug
>
#include
"kalzium_libscience_d
ebug
.h"
#include
<QFile>
#include
<QList>
...
...
@@ -97,7 +97,7 @@ bool SpectrumParser::endElement(const QString&, const QString& localName, const
}
else
if
(
localName
==
QLatin1String
(
"peakList"
))
{
d
->
inSpectrumList_
=
false
;
}
else
if
(
localName
==
QLatin1String
(
"peak"
))
{
//X qDebug() << "in 'peak'" << " with this data: " << d->currentPeak->intensity << " (intensity)" ;
//X q
C
Debug(
KALZIUM_LIBSCIENCE_LOG
) << "in 'peak'" << " with this data: " << d->currentPeak->intensity << " (intensity)" ;
d
->
currentSpectrum
->
addPeak
(
d
->
currentPeak
);
d
->
currentPeak
=
nullptr
;
d
->
inPeak_
=
false
;
...
...
src/CMakeLists.txt
View file @
6fa45408
...
...
@@ -70,7 +70,7 @@ ki18n_wrap_ui(kalziumtools_SRCS
# calculator/massCalculator.ui
)
ecm_qt_declare_logging_category
(
kalziumtools_SRCS HEADER kalzium_debug.h IDENTIFIER KALZIUM_LOG CATEGORY_NAME org.kde.kalzium DESCRIPTION
"Kalzium"
EXPORT KALZIUM
L
)
ecm_qt_declare_logging_category
(
kalziumtools_SRCS HEADER kalzium_debug.h IDENTIFIER KALZIUM_LOG CATEGORY_NAME org.kde.kalzium DESCRIPTION
"Kalzium"
EXPORT KALZIUM
)
set
(
kalzium_SRCS
${
kalziumtools_SRCS
}
detailedgraphicaloverview.cpp
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment