8 Commits

36 changed files with 861 additions and 742 deletions

View File

@ -5,7 +5,7 @@ if (CMAKE_VERSION GREATER_EQUAL 3.12)
cmake_policy(SET CMP0075 NEW)
endif (CMAKE_VERSION GREATER_EQUAL 3.12)
project(musrfit VERSION 1.6.2 LANGUAGES C CXX)
project(musrfit VERSION 1.6.3 LANGUAGES C CXX)
#--- musrfit specific options -------------------------------------------------
option(nexus "build optional NeXus support. Needed for ISIS" OFF)

View File

@ -12,6 +12,12 @@ or
https://bitbucket.org/muonspin/musrfit/commits/all
Release of V1.6.3, 2020/07/27
=============================
A single asymmetry plot allows to toggle the color of the theory function line
by the key 't'.
Release of V1.6.2, 2020/06/17
=============================

View File

@ -141,6 +141,9 @@ Additionally, some functions can be accessed using *key-shortcuts*:
reset the plotting range to the area given in the msr file ("un-zoom").
**c**
toggles between normal and cross-hair cursor.
**t**
a plot of a **single** data set allows to toggle the color of the theory function line.
.. index:: musrFT
.. _musrFT:

View File

@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '1.6.2',
VERSION: '1.6.3',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Acknowledgements &#8212; musrfit 1.6.2 documentation</title>
<title>Acknowledgements &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="musr-root.html" title="MusrRoot - an Extensible Open File Format for μSR"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -100,12 +100,12 @@ extremely competent way to deal with his projects as well as to deal with the ch
<li class="right" >
<a href="musr-root.html" title="MusrRoot - an Extensible Open File Format for μSR"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>any2many - a Universal μSR-file-format converter &#8212; musrfit 1.6.2 documentation</title>
<title>any2many - a Universal μSR-file-format converter &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="msr2data.html" title="msr2data - A Program for Automatically Processing Multiple musrfit msr Files"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -90,12 +90,12 @@ For a detailed description see <a class="reference internal" href="user-manual.h
<li class="right" >
<a href="msr2data.html" title="msr2data - A Program for Automatically Processing Multiple musrfit msr Files"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Bugtracking &#8212; musrfit 1.6.2 documentation</title>
<title>Bugtracking &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -26,7 +26,7 @@
<li class="right" >
<a href="acknowledgement.html" title="Acknowledgements"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -81,12 +81,12 @@ or send an e-mail to A. Suter at PSI.</p>
<li class="right" >
<a href="acknowledgement.html" title="Acknowledgements"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>How to Cite musrfit? &#8212; musrfit 1.6.2 documentation</title>
<title>How to Cite musrfit? &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="index.html" title="Welcome to the musrfit documentation!"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -102,12 +102,12 @@
<li class="right" >
<a href="index.html" title="Welcome to the musrfit documentation!"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -5,7 +5,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Index &#8212; musrfit 1.6.2 documentation</title>
<title>Index &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -23,7 +23,7 @@
<li class="right" style="margin-right: 10px">
<a href="#" title="General Index"
accesskey="I">index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -613,12 +613,12 @@
<li class="right" style="margin-right: 10px">
<a href="#" title="General Index"
>index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Welcome to the musrfit documentation! &#8212; musrfit 1.6.2 documentation</title>
<title>Welcome to the musrfit documentation! &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -26,7 +26,7 @@
<li class="right" >
<a href="cite.html" title="How to Cite musrfit?"
accesskey="N">next</a> |</li>
<li class="nav-item nav-item-0"><a href="#">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="#">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -168,12 +168,12 @@
<li class="right" >
<a href="cite.html" title="How to Cite musrfit?"
>next</a> |</li>
<li class="nav-item nav-item-0"><a href="#">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="#">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>msr2data - A Program for Automatically Processing Multiple musrfit msr Files &#8212; musrfit 1.6.2 documentation</title>
<title>msr2data - A Program for Automatically Processing Multiple musrfit msr Files &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="mupp.html" title="mupp - μSR Parameter Plotter"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -418,12 +418,12 @@ fit serves as template for the second and so on. The template field stays empty
<li class="right" >
<a href="mupp.html" title="mupp - μSR Parameter Plotter"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>mupp - μSR Parameter Plotter &#8212; musrfit 1.6.2 documentation</title>
<title>mupp - μSR Parameter Plotter &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="musredit.html" title="musredit: the GUI Based Interface to musrfit"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -298,12 +298,12 @@ SCRIPT COMMANDS:
<li class="right" >
<a href="musredit.html" title="musredit: the GUI Based Interface to musrfit"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>MusrRoot - an Extensible Open File Format for μSR &#8212; musrfit 1.6.2 documentation</title>
<title>MusrRoot - an Extensible Open File Format for μSR &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="any2many.html" title="any2many - a Universal μSR-file-format converter"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -910,12 +910,12 @@ the entry has been added. The last token, <code class="docutils literal notransl
<li class="right" >
<a href="any2many.html" title="any2many - a Universal μSR-file-format converter"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>musredit: the GUI Based Interface to musrfit &#8212; musrfit 1.6.2 documentation</title>
<title>musredit: the GUI Based Interface to musrfit &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="setup-dks.html" title="Setting up musrfit / DKS: High Speed Fitting with GPUs"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -531,12 +531,12 @@ the corresponding fit parameter value, except the phases where the step will be
<li class="right" >
<a href="setup-dks.html" title="Setting up musrfit / DKS: High Speed Fitting with GPUs"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Search &#8212; musrfit 1.6.2 documentation</title>
<title>Search &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
@ -27,7 +27,7 @@
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -75,12 +75,12 @@
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Setting up musrfit / DKS: High Speed Fitting with GPUs &#8212; musrfit 1.6.2 documentation</title>
<title>Setting up musrfit / DKS: High Speed Fitting with GPUs &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="setup-standard.html" title="Setting up musrfit on Different Platforms"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -309,12 +309,12 @@ The only thing you need <code class="docutils literal notranslate"><span class="
<li class="right" >
<a href="setup-standard.html" title="Setting up musrfit on Different Platforms"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Setting up musrfit on Different Platforms &#8212; musrfit 1.6.2 documentation</title>
<title>Setting up musrfit on Different Platforms &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="user-libs.html" title="Documentation of user libs (user functions)"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -1293,12 +1293,12 @@ $ musrview test-histo-ROOT-NPP.msr
<li class="right" >
<a href="user-libs.html" title="Documentation of user libs (user functions)"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Tutorial for musrfit &#8212; musrfit 1.6.2 documentation</title>
<title>Tutorial for musrfit &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="cite.html" title="How to Cite musrfit?"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -431,12 +431,12 @@ For a complete description please refer to the manuals of <a class="reference in
<li class="right" >
<a href="cite.html" title="How to Cite musrfit?"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Documentation of user libs (user functions) &#8212; musrfit 1.6.2 documentation</title>
<title>Documentation of user libs (user functions) &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="user-manual.html" title="User manual"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -647,12 +647,12 @@ K(m)&amp;=\int_0^{\pi/2}\frac{\mathrm d\varphi}{\sqrt{1-m^2\sin^2{\varphi}}},\en
<li class="right" >
<a href="user-manual.html" title="User manual"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>User manual &#8212; musrfit 1.6.2 documentation</title>
<title>User manual &#8212; musrfit 1.6.3 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
@ -30,7 +30,7 @@
<li class="right" >
<a href="tutorial.html" title="Tutorial for musrfit"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
@ -148,6 +148,8 @@ Supported values for <code class="docutils literal notranslate"><span class="pre
</dd>
<dt><strong>c</strong></dt><dd><p>toggles between normal and cross-hair cursor.</p>
</dd>
<dt><strong>t</strong></dt><dd><p>a plot of a <strong>single</strong> data set allows to toggle the color of the theory function line.</p>
</dd>
</dl>
</div>
</div>
@ -2465,12 +2467,12 @@ In case this cannot be ensured, the parallelization can be disabled by <em>di
<li class="right" >
<a href="tutorial.html" title="Tutorial for musrfit"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.2 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">musrfit 1.6.3 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, Andreas Suter.
Last updated on Jun 17, 2020.
Last updated on Jul 27, 2020.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.2.
</div>
</body>

View File

@ -125,6 +125,7 @@ PMusrCanvas::PMusrCanvas()
fValid = false;
fAveragedView = false;
fDifferenceView = false;
fToggleColor = false;
fCurrentPlotView = PV_DATA;
fPreviousPlotView = PV_DATA;
fPlotType = -1;
@ -1182,6 +1183,19 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
fDataTheoryPad->SetCrosshair(0);
}
fMainCanvas->Update();
} else if (x == 't') { // toggle theory color
if (fData.size() == 1) { // only do something if there is a single data set
if (fToggleColor) {
fData[0].theory->SetLineColor(kRed);
fData[0].theory->SetLineWidth(2);
} else {
fData[0].theory->SetLineColor(fColorList[0]);
fData[0].theory->SetLineWidth(1);
}
fToggleColor = !fToggleColor;
fDataTheoryPad->Modified();
fMainCanvas->Update();
}
} else {
fMainCanvas->Update();
}
@ -2384,6 +2398,7 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
fValid = false;
fAveragedView = false;
fDifferenceView = false;
fToggleColor = false;
fCurrentPlotView = PV_DATA;
fPreviousPlotView = PV_DATA;
fPlotType = -1;

View File

@ -244,6 +244,7 @@ class PMusrCanvas : public TObject, public TQObject
Bool_t fValid; ///< if true, everything looks OK
Bool_t fAveragedView; ///< tag showing that the averaged view or normal view should be presented.
Bool_t fDifferenceView; ///< tag showing that the shown data, fourier, are the difference between data and theory
Bool_t fToggleColor; ///< tag showing if a single histo theory is color toggled
Int_t fCurrentPlotView; ///< tag showing what the current plot view is: data, fourier, ...
Int_t fPreviousPlotView; ///< tag showing the previous plot view
Int_t fPlotType; ///< plot type tag: -1 == undefined, MSR_PLOT_SINGLE_HISTO == single histogram, MSR_PLOT_ASYM == asymmetry, MSR_PLOT_BNMR == beta-NMR asymmetry, MSR_PLOT_MU_MINUS == mu minus (not yet implemented), MSR_PLOT_NON_MUSR == non-muSR

View File

@ -32,6 +32,7 @@
#include <QMessageBox>
#include <QString>
#include <QStringRef>
#include <QFile>
#include <QTextStream>
#include <QVector>
@ -82,9 +83,56 @@ void PmuppColor::setRGB(const int r, const int g, const int b)
*
* \param admin pointer to an admin class instance.
*/
PmuppAdminXMLParser::PmuppAdminXMLParser(PmuppAdmin *admin) : fAdmin(admin)
PmuppAdminXMLParser::PmuppAdminXMLParser(const QString& fln, PmuppAdmin *admin) : fAdmin(admin)
{
fValid = false;
fKeyWord = eEmpty;
QFile file(fln);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// warning and create default - STILL MISSING
}
fValid = parse(&file);
}
//--------------------------------------------------------------------------
/**
* <p>parse the mupp startup xml-file.
*
* \param device QFile object of the mupp startup xml-file
*
* @return true on success, false otherwise
*/
bool PmuppAdminXMLParser::parse(QIODevice *device)
{
fXml.setDevice(device);
bool expectChars = false;
while (!fXml.atEnd()) {
fXml.readNext();
if (fXml.isStartDocument()) {
startDocument();
} else if (fXml.isStartElement()) {
startElement();
expectChars = true;
} else if (fXml.isCharacters() && expectChars) {
characters();
} else if (fXml.isEndElement()) {
endElement();
expectChars = false;
} else if (fXml.isEndDocument()) {
endDocument();
}
}
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
return true;
}
//--------------------------------------------------------------------------
@ -93,6 +141,7 @@ PmuppAdminXMLParser::PmuppAdminXMLParser(PmuppAdmin *admin) : fAdmin(admin)
*/
bool PmuppAdminXMLParser::startDocument()
{
// nothing to be done here for now
return true;
}
@ -100,13 +149,11 @@ bool PmuppAdminXMLParser::startDocument()
/**
* <p>Routine called when a new XML tag is found. Here it is used
* to set a tag for filtering afterwards the content.
*
* \param qName name of the XML tag.
*/
bool PmuppAdminXMLParser::startElement( const QString&, const QString&,
const QString& qName,
const QXmlAttributes& )
bool PmuppAdminXMLParser::startElement()
{
QStringRef qName = fXml.name();
if (qName == "path_file_name") {
fKeyWord = eRecentFile;
} else if (qName == "dark_theme") {
@ -125,10 +172,8 @@ bool PmuppAdminXMLParser::startElement( const QString&, const QString&,
* <p>Routine called when the end XML tag is found. It is used to
* put the filtering tag to 'empty'. It also resets the fFunc flag in case
* the entry was a theory function.
*
* \param qName name of the element.
*/
bool PmuppAdminXMLParser::endElement( const QString&, const QString&, const QString& )
bool PmuppAdminXMLParser::endElement()
{
fKeyWord = eEmpty;
@ -139,11 +184,13 @@ bool PmuppAdminXMLParser::endElement( const QString&, const QString&, const QStr
/**
* <p>This routine delivers the content of an XML tag. It fills the
* content into the load data structure.
*
* \param str keeps the content of the XML tag.
*/
bool PmuppAdminXMLParser::characters(const QString& str)
bool PmuppAdminXMLParser::characters()
{
QString str = *fXml.text().string();
if (str.isEmpty())
return true;
bool ok;
int ival, r, g, b;
double dval;
@ -218,66 +265,6 @@ bool PmuppAdminXMLParser::endDocument()
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report XML warnings.
*
* \param exception holds the information of the XML warning
*/
bool PmuppAdminXMLParser::warning( const QXmlParseException & exception )
{
QString msg;
msg = QString("**WARNING** while parsing mupp_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**WARNING MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report recoverable XML errors.
*
* \param exception holds the information of the XML recoverable errors.
*/
bool PmuppAdminXMLParser::error( const QXmlParseException & exception )
{
QString msg;
msg = QString("**ERROR** while parsing mupp_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report fatal XML errors.
*
* \param exception holds the information of the XML fatal errors.
*/
bool PmuppAdminXMLParser::fatalError( const QXmlParseException & exception )
{
QString msg;
msg = QString("**FATAL ERROR** while parsing mupp_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
// implementation of PmuppAdmin class
//--------------------------------------------------------------------------
@ -315,21 +302,16 @@ PmuppAdmin::PmuppAdmin() : QObject(), fDarkTheme(false)
}
}
if (QFile::exists(pathFln)) { // administration file present
PmuppAdminXMLParser handler(this);
QFile xmlFile(pathFln);
QXmlInputSource source( &xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
reader.setErrorHandler( &handler );
if (!reader.parse( source )) {
QMessageBox::critical(0, "ERROR",
if (QFile::exists(pathFln)) { // administration file present
PmuppAdminXMLParser handler(pathFln, this);
if (!handler.isValid()) {
QMessageBox::critical(0, "**ERROR**",
"Error parsing mupp_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
} else {
QMessageBox::critical(0, "ERROR",
QMessageBox::critical(0, "**ERROR**",
"Couldn't find the mupp_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return;

View File

@ -34,7 +34,7 @@
#include <QVector>
#include <QMap>
#include <QPixmap>
#include <QtXml>
#include <QXmlStreamReader>
#include "mupp.h"
@ -93,29 +93,28 @@ class PmuppMarker {
* necessary informations about executable pathes, online help informations,
* default font sizes, etc.
*/
class PmuppAdminXMLParser : public QXmlDefaultHandler
class PmuppAdminXMLParser
{
public:
PmuppAdminXMLParser(PmuppAdmin*);
PmuppAdminXMLParser(const QString &fln, PmuppAdmin*);
virtual ~PmuppAdminXMLParser() {}
virtual bool isValid() { return fValid; }
private:
enum EAdminKeyWords {eEmpty, eRecentFile, eDarkTheme, eMarker, eColor};
bool parse(QIODevice *device);
bool startDocument();
bool startElement( const QString&, const QString&, const QString& ,
const QXmlAttributes& );
bool endElement( const QString&, const QString&, const QString& );
bool characters(const QString&);
bool startElement();
bool endElement();
bool characters();
bool endDocument();
bool warning( const QXmlParseException & exception );
bool error( const QXmlParseException & exception );
bool fatalError( const QXmlParseException & exception );
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
PmuppAdmin *fAdmin; ///< a pointer to the main administration class object
QXmlStreamReader fXml; ///< xml stream reader object
bool fValid; ///< flag showing if XML read has been successful
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
PmuppAdmin *fAdmin; ///< a pointer to the main administration class object
};
//---------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <cmath>
#include <iostream>
#include <QProcessEnvironment>

View File

@ -37,6 +37,8 @@
#include <QString>
#include <QStringList>
#include <QVector>
#include <QTextStream>
#include <QTimer>
#include "mupp_version.h"
#include "PmuppScript.h"

View File

@ -70,9 +70,16 @@ namespace mupp { namespace ast
fun_sin,
fun_cos,
fun_tan,
fun_sinh,
fun_cosh,
fun_tanh,
fun_asin,
fun_acos,
fun_atan,
fun_exp,
fun_log,
fun_ln
fun_ln,
fun_sqrt
};
struct nil {};

View File

@ -86,9 +86,16 @@ namespace mupp { namespace parser
("sin", ast::fun_sin)
("cos", ast::fun_cos)
("tan", ast::fun_tan)
("sinh", ast::fun_sinh)
("cosh", ast::fun_cosh)
("tanh", ast::fun_tanh)
("asin", ast::fun_asin)
("acos", ast::fun_acos)
("atan", ast::fun_atan)
("exp", ast::fun_exp)
("log", ast::fun_log)
("ln", ast::fun_ln)
("sqrt", ast::fun_sqrt)
;
///////////////////////////////////////////////////////////////////////

View File

@ -102,9 +102,16 @@ namespace mupp { namespace prog {
case ast::fun_sin:
case ast::fun_cos:
case ast::fun_tan:
case ast::fun_sinh:
case ast::fun_cosh:
case ast::fun_tanh:
case ast::fun_asin:
case ast::fun_acos:
case ast::fun_atan:
case ast::fun_exp:
case ast::fun_log:
case ast::fun_ln:
case ast::fun_sqrt:
break;
default:
BOOST_ASSERT(0);
@ -412,6 +419,30 @@ namespace mupp { namespace prog {
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = tan(vec[i]);
break;
case ast::fun_sinh:
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = sinh(vec[i]);
break;
case ast::fun_cosh:
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = cosh(vec[i]);
break;
case ast::fun_tanh:
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = tanh(vec[i]);
break;
case ast::fun_asin:
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = asin(vec[i]);
break;
case ast::fun_acos:
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = acos(vec[i]);
break;
case ast::fun_atan:
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = atan(vec[i]);
break;
case ast::fun_exp:
for (unsigned int i=0; i<vec.size(); i++)
vec[i] = exp(vec[i]);
@ -436,6 +467,16 @@ namespace mupp { namespace prog {
}
}
break;
case ast::fun_sqrt:
for (unsigned int i=0; i<vec.size(); i++) {
if (vec[i] <= 0.0) {
BOOST_ASSERT(0);
break;
} else {
vec[i] = sqrt(vec[i]);
}
}
break;
default:
BOOST_ASSERT(0);
break;

View File

@ -36,6 +36,9 @@ using namespace std;
#include <QFile>
#include <QTextStream>
#include <QVector>
#include <QXmlStreamAttributes>
#include <QtDebug>
#include "PAdmin.h"
@ -47,28 +50,78 @@ using namespace std;
*
* \param admin pointer to an admin class instance.
*/
PFuncXMLParser::PFuncXMLParser(PAdmin *admin) : fAdmin(admin)
PFuncXMLParser::PFuncXMLParser(const QString& fln, PAdmin *admin) : fAdmin(admin)
{
fValid = false;
fKeyWord = eEmpty;
QFile file(fln);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// warning and create default - STILL MISSING
}
fValid = parse(&file);
}
//--------------------------------------------------------------------------
/**
* <p>
* <p>parse musrfit_funcs.xml
*
* \param device QFile object of musrfit_funcs.xml
*
* @return true on success, false otherwise
*/
bool PFuncXMLParser::startDocument()
bool PFuncXMLParser::parse(QIODevice *device)
{
fXml.setDevice(device);
bool expectChars = false;
while (!fXml.atEnd()) {
fXml.readNext();
if (fXml.isStartDocument()) {
startDocument();
} else if (fXml.isStartElement()) {
startElement();
expectChars = true;
} else if (fXml.isCharacters() && expectChars) {
characters();
} else if (fXml.isEndElement()) {
endElement();
expectChars = false;
} else if (fXml.isEndDocument()) {
endDocument();
}
}
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
return true;
}
//--------------------------------------------------------------------------
/**
* <p>
* <p>Routine called at the beginning of the XML parsing process.
*/
bool PFuncXMLParser::startElement(const QString&, const QString&,
const QString& qName,
const QXmlAttributes& qAttr)
bool PFuncXMLParser::startDocument()
{
// nothing to be done here for now
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Routine called when a new XML tag is found. Here it is used
* to set a tag for filtering afterwards the content.
*/
bool PFuncXMLParser::startElement()
{
QStringRef qName = fXml.name();
QString str;
QString errMsg("");
int ival;
double dval;
@ -83,29 +136,26 @@ bool PFuncXMLParser::startElement(const QString&, const QString&,
} else if (qName == "theo_fun") {
fKeyWord = eTemplateFunc;
} else if (qName == "theo_map") {
QXmlStreamAttributes qAttr = fXml.attributes();
if (qAttr.count() != 2) {
errMsg = QString("theo_map should have 2 attributes, called 'no', and 'name', found %1").arg(qAttr.count());
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
PParam map;
for (int i=0; i<qAttr.count(); i++) {
if (qAttr.qName(i) == "no") {
ival = qAttr.value(i).toInt(&ok);
if (!ok) {
errMsg = QString("theo_map attribute 'no' is not a number (%1)").arg(qAttr.value(i));
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
map.setNumber(ival);
} else if (qAttr.qName(i) == "name") {
map.setName(qAttr.value(i));
} else {
errMsg = QString("found unkown theo_map attribute (%1)").arg(qAttr.qName(i));
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
// get map number
str = qAttr.value("no").toString();
ival = str.toInt(&ok);
if (!ok) {
errMsg = QString("theo_map attribute 'no' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
map.setNumber(ival);
// get map name
str = qAttr.value("name").toString();
map.setName(str);
// check that all necessary attributes where found
if ((map.getName() == "UnDef") || (map.getNumber() == -1)) {
errMsg = QString("found theo_map with missing attribute(s)");
@ -114,45 +164,51 @@ bool PFuncXMLParser::startElement(const QString&, const QString&,
}
fTheoTemplate.appendMap(map);
} else if (qName == "template_param") {
QXmlStreamAttributes qAttr = fXml.attributes();
if ((qAttr.count() != 4) && (qAttr.count() != 6)) {
errMsg = QString("template_param should have 4 or 6 attributes, called\n'no', 'name', 'value', 'step', ['boundLow', 'boundHigh'] found %1").arg(qAttr.count());
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
PParam param;
for (int i=0; i<qAttr.count(); i++) {
if (qAttr.qName(i) == "no") {
ival = qAttr.value(i).toInt(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'no' is not a number (%1)").arg(qAttr.value(i));
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
param.setNumber(ival);
} else if (qAttr.qName(i) == "name") {
param.setName(qAttr.value(i));
} else if (qAttr.qName(i) == "value") {
dval = qAttr.value(i).toDouble(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'value' is not a number (%1)").arg(qAttr.value(i));
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
param.setValue(dval);
} else if (qAttr.qName(i) == "step") {
dval = qAttr.value(i).toDouble(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'step' is not a number (%1)").arg(qAttr.value(i));
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
param.setStep(dval);
} else if (qAttr.qName(i) == "boundLow") {
param.setBoundLow(qAttr.qName(i));
} else if (qAttr.qName(i) == "boundHigh") {
param.setBoundHigh(qAttr.qName(i));
}
// parameter number
str = qAttr.value("no").toString();
ival = str.toInt(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'no' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
param.setNumber(ival);
// parameter name
str = qAttr.value("name").toString();
param.setName(str);
// parameter value
str = qAttr.value("value").toString();
dval = str.toDouble(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'value' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
param.setValue(dval);
// parameter step
str = qAttr.value("step").toString();
dval = str.toDouble(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'step' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
return false;
}
param.setStep(dval);
// parameter lower bound
str = qAttr.value("boundLow").toString();
if (!str.isEmpty())
param.setBoundLow(str);
// parameter upper bound
str = qAttr.value("boundHigh").toString();
if (!str.isEmpty())
param.setBoundHigh(str);
fTheoTemplate.appendParam(param);
} else if (qName == "func") {
fFunc.initFunc();
@ -177,12 +233,16 @@ bool PFuncXMLParser::startElement(const QString&, const QString&,
//--------------------------------------------------------------------------
/**
* <p>
* <p>Routine called when the end XML tag is found. It is used to
* put the filtering tag to 'empty'. It also resets the fFunc flag in case
* the entry was a theory function.
*/
bool PFuncXMLParser::endElement( const QString&, const QString&, const QString &qName )
bool PFuncXMLParser::endElement()
{
fKeyWord = eEmpty;
QStringRef qName = fXml.name();
if (qName == "theo_template") {
fAdmin->fTheoTemplate.push_back(fTheoTemplate);
} else if (qName == "func") {
@ -196,10 +256,15 @@ bool PFuncXMLParser::endElement( const QString&, const QString&, const QString &
//--------------------------------------------------------------------------
/**
* <p>
* <p>This routine delivers the content of an XML tag. It fills the
* content into the load data structure.
*/
bool PFuncXMLParser::characters(const QString &str)
bool PFuncXMLParser::characters()
{
QString str = *fXml.text().string();
if (str.isEmpty())
return true;
bool ok;
int ival;
double dval;
@ -246,82 +311,77 @@ bool PFuncXMLParser::characters(const QString &str)
//--------------------------------------------------------------------------
/**
* <p>
* <p>Called at the end of the XML parse process. It checks if default paths
* contain system variables, and if so expand them for the further use.
*/
bool PFuncXMLParser::endDocument()
{
return true;
}
//--------------------------------------------------------------------------
/**
* <p>
*/
bool PFuncXMLParser::warning( const QXmlParseException & exception )
{
QString msg;
msg = QString("**WARNING** while parsing musrfit_funcs.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**WARNING MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>
*/
bool PFuncXMLParser::error( const QXmlParseException & exception )
{
QString msg;
msg = QString("**ERROR** while parsing musrfit_funcs.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>
*/
bool PFuncXMLParser::fatalError( const QXmlParseException & exception )
{
QString msg;
msg = QString("**FATAL ERROR** while parsing musrfit_funcs.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
// implementation of PInstrumentDefXMLParser class
//--------------------------------------------------------------------------
/**
* <p>XML Parser class for the instrument definition file(s).
*
* \param file name of the instrument definition file(s).
* \param admin pointer to an admin class instance.
*/
PInstrumentDefXMLParser::PInstrumentDefXMLParser(PAdmin *admin) : fAdmin(admin)
PInstrumentDefXMLParser::PInstrumentDefXMLParser(const QString& fln, PAdmin *admin) : fAdmin(admin)
{
fValid = false;
fKeyWord = eEmpty;
fInstituteName = "";
fInstrument = 0;
fSetup = 0;
QFile file(fln);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// warning and create default - STILL MISSING
}
fValid = parse(&file);
}
//--------------------------------------------------------------------------
/**
* <p>parse the instrument definition xml-file(s).
*
* \param device QFile object of the instrument definition xml-file(s).
*
* @return true on success, false otherwise
*/
bool PInstrumentDefXMLParser::parse(QIODevice *device)
{
fXml.setDevice(device);
bool expectChars = false;
while (!fXml.atEnd()) {
fXml.readNext();
if (fXml.isStartDocument()) {
startDocument();
} else if (fXml.isStartElement()) {
startElement();
expectChars = true;
} else if (fXml.isCharacters() && expectChars) {
characters();
} else if (fXml.isEndElement()) {
endElement();
expectChars = false;
} else if (fXml.isEndDocument()) {
endDocument();
}
}
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
return true;
}
//--------------------------------------------------------------------------
@ -330,6 +390,7 @@ PInstrumentDefXMLParser::PInstrumentDefXMLParser(PAdmin *admin) : fAdmin(admin)
*/
bool PInstrumentDefXMLParser::startDocument()
{
// nothing to be done here for now
return true;
}
@ -337,13 +398,11 @@ bool PInstrumentDefXMLParser::startDocument()
/**
* <p>Routine called when a new XML tag is found. Here it is used
* to set a tag for filtering afterwards the content.
*
* \param qName name of the XML tag.
*/
bool PInstrumentDefXMLParser::startElement( const QString&, const QString&,
const QString& qName,
const QXmlAttributes& qAttr)
bool PInstrumentDefXMLParser::startElement()
{
QStringRef qName = fXml.name();
bool ok;
double dval;
double ival;
@ -356,6 +415,7 @@ bool PInstrumentDefXMLParser::startElement( const QString&, const QString&,
fKeyWord = eInstitute;
} else if (qName == "instrument") {
fKeyWord = eInstrument;
QXmlStreamAttributes qAttr = fXml.attributes();
if (qAttr.count() != 1) {
errMsg = QString("instrument should have 1 attribute, called 'name', found %1").arg(qAttr.count());
QMessageBox::critical(0, "ERROR", errMsg);
@ -369,7 +429,7 @@ bool PInstrumentDefXMLParser::startElement( const QString&, const QString&,
// create an instrument object
fInstrument = new PInstrument();
fInstrument->setInstitue(fInstituteName);
fInstrument->setName(qAttr.value(0));
fInstrument->setName(qAttr.value("name").toString());
} else if (qName == "run_name_template") {
fKeyWord = eRunNameTemplate;
} else if (qName == "beamline") {
@ -378,23 +438,26 @@ bool PInstrumentDefXMLParser::startElement( const QString&, const QString&,
fKeyWord = eDataFileFormat;
} else if (qName == "tf") {
fKeyWord = eTf;
QXmlStreamAttributes qAttr = fXml.attributes();
fSetup = new PSetup();
if (qAttr.count() == 1)
fSetup->setName(qAttr.value(0));
fSetup->setName(qAttr.value("name").toString());
else
fSetup->setName("Default");
} else if (qName == "zf") {
fKeyWord = eZf;
QXmlStreamAttributes qAttr = fXml.attributes();
fSetup = new PSetup();
if (qAttr.count() == 1)
fSetup->setName(qAttr.value(0));
fSetup->setName(qAttr.value("name").toString());
else
fSetup->setName("Default");
} else if (qName == "lf") {
fKeyWord = eLf;
QXmlStreamAttributes qAttr = fXml.attributes();
fSetup = new PSetup();
if (qAttr.count() == 1)
fSetup->setName(qAttr.value(0));
fSetup->setName(qAttr.value("name").toString());
else
fSetup->setName("Default");
} else if (qName == "no_of_detectors") {
@ -406,94 +469,78 @@ bool PInstrumentDefXMLParser::startElement( const QString&, const QString&,
} else if (qName == "asym_bkg_range") {
fKeyWord = eBkgRange;
} else if (qName == "logic_detector") {
QXmlStreamAttributes qAttr = fXml.attributes();
if (qAttr.count() < 3)
return false;
PDetector detect;
int count=0;
for (int i=0; i<qAttr.count(); i++) {
if (qAttr.localName(i) == "name") {
detect.setName(qAttr.value(i)); // detector name
count++;
} else if (qAttr.localName(i) == "rel_phase") {
str = qAttr.value(i);
dval = str.toDouble(&ok);
if (ok) {
detect.setRelGeomPhase(dval);
count++;
}
} else if (qAttr.localName(i) == "forward") {
str = qAttr.value(i);
strL.clear();
strL = str.split(' ');
forward.clear();
for (int j=0; j<strL.size(); j++) {
ival = strL[j].toInt(&ok);
if (!ok)
return false;
forward.push_back(ival);
}
detect.setForwards(forward);
count++;
}
}
if (count != 3) // i.e. didn't find all needed attributes
// detector name
str = qAttr.value("name").toString();
detect.setName(str);
// detector relative phase
str = qAttr.value("rel_phase").toString();
dval = str.toDouble(&ok);
if (!ok) {
return false;
}
detect.setRelGeomPhase(dval);
// detector number(s)
str = qAttr.value("forward").toString();
strL.clear();
strL = str.split(' ');
forward.clear();
for (int j=0; j<strL.size(); j++) {
ival = strL[j].toInt(&ok);
if (!ok)
return false;
forward.push_back(ival);
}
detect.setForwards(forward);
fSetup->addDetector(detect);
} else if (qName == "logic_asym_detector") {
QXmlStreamAttributes qAttr = fXml.attributes();
if (qAttr.count() != 5)
return false;
PDetector detect;
int count=0;
for (int i=0; i<5; i++) {
if (qAttr.localName(i) == "name") {
detect.setName(qAttr.value(i)); // detector name
count++;
} else if (qAttr.localName(i) == "rel_phase") {
str = qAttr.value(i);
dval = str.toDouble(&ok);
if (ok) {
detect.setRelGeomPhase(dval);
count++;
}
} else if (qAttr.localName(i) == "forward") {
str = qAttr.value(i);
strL.clear();
strL = str.split(' ');
forward.clear();
for (int j=0; j<strL.size(); j++) {
ival = strL[j].toInt(&ok);
if (!ok)
return false;
forward.push_back(ival);
}
detect.setForwards(forward);
count++;
} else if (qAttr.localName(i) == "backward") {
str = qAttr.value(i);
strL.clear();
strL = str.split(' ');
backward.clear();
for (int j=0; j<strL.size(); j++) {
ival = strL[j].toInt(&ok);
if (!ok)
return false;
backward.push_back(ival);
}
detect.setBackwards(backward);
count++;
} else if (qAttr.localName(i) == "alpha") {
str = qAttr.value(i);
dval = str.toDouble(&ok);
if (!ok)
return false;
detect.setAlpha(dval);
count++;
}
}
if (count != 5) // i.e. didn't find all needed attributes
// detector name
str = qAttr.value("name").toString();
detect.setName(str);
// detector relative phase
str = qAttr.value("rel_phase").toString();
dval = str.toDouble(&ok);
if (!ok) {
return false;
}
detect.setRelGeomPhase(dval);
// detector forward
str = qAttr.value("forward").toString();
strL.clear();
strL = str.split(' ');
forward.clear();
for (int j=0; j<strL.size(); j++) {
ival = strL[j].toInt(&ok);
if (!ok)
return false;
forward.push_back(ival);
}
detect.setForwards(forward);
// detector backward
str = qAttr.value("backward").toString();
strL.clear();
strL = str.split(' ');
backward.clear();
for (int j=0; j<strL.size(); j++) {
ival = strL[j].toInt(&ok);
if (!ok)
return false;
backward.push_back(ival);
}
detect.setForwards(backward);
// detector alpha
str = qAttr.value("alpha").toString();
dval = str.toDouble(&ok);
if (!ok)
return false;
detect.setAlpha(dval);
fSetup->addAsymDetector(detect);
}
@ -505,13 +552,13 @@ bool PInstrumentDefXMLParser::startElement( const QString&, const QString&,
* <p>Routine called when the end XML tag is found. It is used to
* put the filtering tag to 'empty'. It also resets the fFunc flag in case
* the entry was a theory function.
*
* \param qName name of the element.
*/
bool PInstrumentDefXMLParser::endElement( const QString&, const QString&, const QString &qName )
bool PInstrumentDefXMLParser::endElement()
{
fKeyWord = eEmpty;
QStringRef qName = fXml.name();
if (qName == "instrument") {
// store instrument
fAdmin->addInstrument(fInstituteName, *fInstrument);
@ -557,11 +604,13 @@ bool PInstrumentDefXMLParser::endElement( const QString&, const QString&, const
/**
* <p>This routine delivers the content of an XML tag. It fills the
* content into the load data structure.
*
* \param str keeps the content of the XML tag.
*/
bool PInstrumentDefXMLParser::characters(const QString& str)
bool PInstrumentDefXMLParser::characters()
{
QString str = *fXml.text().string();
if (str.isEmpty())
return true;
bool ok;
int ival, start, end;
QString errMsg;
@ -649,66 +698,6 @@ bool PInstrumentDefXMLParser::endDocument()
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report XML warnings.
*
* \param exception holds the information of the XML warning
*/
bool PInstrumentDefXMLParser::warning( const QXmlParseException & exception )
{
QString msg;
msg = QString("**WARNING** while parsing instrument_def_XXX.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**WARNING MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report recoverable XML errors.
*
* \param exception holds the information of the XML recoverable errors.
*/
bool PInstrumentDefXMLParser::error( const QXmlParseException & exception )
{
QString msg;
msg = QString("**ERROR** while parsing instrument_def_XXX.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report fatal XML errors.
*
* \param exception holds the information of the XML fatal errors.
*/
bool PInstrumentDefXMLParser::fatalError( const QXmlParseException & exception )
{
QString msg;
msg = QString("**FATAL ERROR** while parsing parsing instrument_def_XXX.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
// implementation of PMusrWizDefault class
//--------------------------------------------------------------------------
@ -730,9 +719,56 @@ PMusrWizDefault::PMusrWizDefault()
*
* \param admin pointer to an admin class instance.
*/
PMusrWizDefaultXMLParser::PMusrWizDefaultXMLParser(PAdmin *admin) : fAdmin(admin)
PMusrWizDefaultXMLParser::PMusrWizDefaultXMLParser(const QString& fln, PAdmin *admin) : fAdmin(admin)
{
fValid = false;
fKeyWord = eEmpty;
QFile file(fln);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// warning and create default - STILL MISSING
}
fValid = parse(&file);
}
//--------------------------------------------------------------------------
/**
* <p>parse the musrWiz startup xml-file.
*
* \param device QFile object of the musrWiz startup xml-file
*
* @return true on success, false otherwise
*/
bool PMusrWizDefaultXMLParser::parse(QIODevice *device)
{
fXml.setDevice(device);
bool expectChars = false;
while (!fXml.atEnd()) {
fXml.readNext();
if (fXml.isStartDocument()) {
startDocument();
} else if (fXml.isStartElement()) {
startElement();
expectChars = true;
} else if (fXml.isCharacters() && expectChars) {
characters();
} else if (fXml.isEndElement()) {
endElement();
expectChars = false;
} else if (fXml.isEndDocument()) {
endDocument();
}
}
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
return true;
}
//--------------------------------------------------------------------------
@ -741,6 +777,7 @@ PMusrWizDefaultXMLParser::PMusrWizDefaultXMLParser(PAdmin *admin) : fAdmin(admin
*/
bool PMusrWizDefaultXMLParser::startDocument()
{
// nothing to be done here for now
return true;
}
@ -748,13 +785,11 @@ bool PMusrWizDefaultXMLParser::startDocument()
/**
* <p>Routine called when a new XML tag is found. Here it is used
* to set a tag for filtering afterwards the content.
*
* \param qName name of the XML tag.
*/
bool PMusrWizDefaultXMLParser::startElement( const QString&, const QString&,
const QString& qName,
const QXmlAttributes& )
bool PMusrWizDefaultXMLParser::startElement()
{
QStringRef qName = fXml.name();
if (qName == "institute") {
fKeyWord = eInstitute;
} else if (qName == "instrument") {
@ -771,10 +806,8 @@ bool PMusrWizDefaultXMLParser::startElement( const QString&, const QString&,
* <p>Routine called when the end XML tag is found. It is used to
* put the filtering tag to 'empty'. It also resets the fFunc flag in case
* the entry was a theory function.
*
* \param qName name of the element.
*/
bool PMusrWizDefaultXMLParser::endElement( const QString&, const QString&, const QString& )
bool PMusrWizDefaultXMLParser::endElement()
{
fKeyWord = eEmpty;
@ -785,11 +818,13 @@ bool PMusrWizDefaultXMLParser::endElement( const QString&, const QString&, const
/**
* <p>This routine delivers the content of an XML tag. It fills the
* content into the load data structure.
*
* \param str keeps the content of the XML tag.
*/
bool PMusrWizDefaultXMLParser::characters(const QString& str)
bool PMusrWizDefaultXMLParser::characters()
{
QString str = *fXml.text().string();
if (str.isEmpty())
return true;
switch (fKeyWord) {
case eInstitute:
fDefault.setInstitute(str);
@ -818,66 +853,6 @@ bool PMusrWizDefaultXMLParser::endDocument()
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report XML warnings.
*
* \param exception holds the information of the XML warning
*/
bool PMusrWizDefaultXMLParser::warning( const QXmlParseException & exception )
{
QString msg;
msg = QString("**WARNING** while parsing musrWiz.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**WARNING MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report recoverable XML errors.
*
* \param exception holds the information of the XML recoverable errors.
*/
bool PMusrWizDefaultXMLParser::error( const QXmlParseException & exception )
{
QString msg;
msg = QString("**ERROR** while parsing musrWiz.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report fatal XML errors.
*
* \param exception holds the information of the XML fatal errors.
*/
bool PMusrWizDefaultXMLParser::fatalError( const QXmlParseException & exception )
{
QString msg;
msg = QString("**FATAL ERROR** while parsing parsing musrWiz.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
// implementation of PAdmin class
//--------------------------------------------------------------------------
@ -1245,12 +1220,8 @@ int PAdmin::loadMusrWizDefault(QString fln)
}
}
PMusrWizDefaultXMLParser handler(this);
QFile xmlFile(fln);
QXmlInputSource source( &xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
if (!reader.parse(source)) {
PMusrWizDefaultXMLParser handler(fln, this);
if (!handler.isValid()) {
QString errMsg = QString("Error parsing %1 file.").arg(fln);
QMessageBox::critical(0, "ERROR", errMsg);
return 1;
@ -1282,12 +1253,8 @@ int PAdmin::loadMusrfitFunc(QString fln)
}
}
PFuncXMLParser handler(this);
QFile xmlFile(fln);
QXmlInputSource source( &xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
if (!reader.parse(source)) {
PFuncXMLParser handler(fln, this);
if (!handler.isValid()) {
QString errMsg = QString("Error parsing %1 musrfit func file.").arg(fln);
QMessageBox::critical(0, "ERROR", errMsg);
return 1;
@ -1326,12 +1293,8 @@ int PAdmin::loadInstrumentDef(QString path, QString fln)
}
}
PInstrumentDefXMLParser handler(this);
QFile xmlFile(pathFln);
QXmlInputSource source( &xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
if (!reader.parse(source)) {
PInstrumentDefXMLParser handler(pathFln, this);
if (!handler.isValid()) {
QString errMsg = QString("Error parsing %1 instrument def file.").arg(pathFln);
QMessageBox::critical(0, "ERROR", errMsg);
return 1;

View File

@ -32,7 +32,10 @@
#include <QObject>
#include <QVector>
#include <QtXml>
#include <QXmlStreamReader>
#include <QIODevice>
#include <QProcessEnvironment>
#include <QDir>
#include "PTheoTemplate.h"
#include "PMusrfitFunc.h"
@ -41,32 +44,32 @@
class PAdmin;
//---------------------------------------------------------------------------
class PFuncXMLParser : public QXmlDefaultHandler
class PFuncXMLParser
{
public:
PFuncXMLParser(PAdmin*);
PFuncXMLParser(const QString &fln, PAdmin*);
virtual ~PFuncXMLParser() {}
virtual bool isValid() { return fValid; }
private:
enum EFuncKeyWords {eEmpty,
eTemplateName, eTemplateTheo, eTemplateFunc,
eName, eAbbrv, eNoOfParam, eParam,
eParamName, eParamValue, eParamMap};
bool parse(QIODevice *device);
bool startDocument();
bool startElement(const QString&, const QString&, const QString& ,
const QXmlAttributes& qAttr);
bool endElement( const QString&, const QString&, const QString& );
bool characters(const QString&);
bool startElement();
bool endElement();
bool characters();
bool endDocument();
bool warning( const QXmlParseException & exception );
bool error( const QXmlParseException & exception );
bool fatalError( const QXmlParseException & exception );
EFuncKeyWords fKeyWord; ///< key word tag to know how to handle the content
PAdmin *fAdmin; ///< a pointer to the main administration class object
QXmlStreamReader fXml; ///< xml stream reader object
bool fValid; ///< flag showing if XML read has been successful
EFuncKeyWords fKeyWord; ///< key word tag to know how to handle the content
PAdmin *fAdmin; ///< a pointer to the main administration class object
PTheoTemplate fTheoTemplate;
PMusrfitFunc fFunc;
@ -74,32 +77,31 @@ class PFuncXMLParser : public QXmlDefaultHandler
};
//---------------------------------------------------------------------------
class PInstrumentDefXMLParser : public QXmlDefaultHandler
class PInstrumentDefXMLParser
{
public:
PInstrumentDefXMLParser(PAdmin*);
PInstrumentDefXMLParser(const QString &fln, PAdmin*);
virtual ~PInstrumentDefXMLParser() {}
virtual bool isValid() { return fValid; }
private:
enum EKeyWords {eEmpty, eInstitute, eInstrument, eRunNameTemplate,
eBeamline, eDataFileFormat, eTf, eZf, eLf,
eNoOfDetectors, eFgbOffset, eLgb, eBkgRange,
eLogicDetector};
bool parse(QIODevice *device);
bool startDocument();
bool startElement(const QString&, const QString&, const QString& ,
const QXmlAttributes& qAttr);
bool endElement( const QString&, const QString&, const QString& );
bool characters(const QString&);
bool startElement();
bool endElement();
bool characters();
bool endDocument();
bool warning( const QXmlParseException & exception );
bool error( const QXmlParseException & exception );
bool fatalError( const QXmlParseException & exception );
EKeyWords fKeyWord; ///< key word tag to know how to handle the content
PAdmin *fAdmin; ///< a pointer to the main administration class object
QXmlStreamReader fXml; ///< xml stream reader object
bool fValid; ///< flag showing if XML read has been successful
EKeyWords fKeyWord; ///< key word tag to know how to handle the content
PAdmin *fAdmin; ///< a pointer to the main administration class object
QString fInstituteName;
PInstrument *fInstrument;
@ -128,27 +130,26 @@ class PMusrWizDefault
};
//---------------------------------------------------------------------------
class PMusrWizDefaultXMLParser : public QXmlDefaultHandler
class PMusrWizDefaultXMLParser
{
public:
PMusrWizDefaultXMLParser(PAdmin*);
PMusrWizDefaultXMLParser(const QString &fln, PAdmin*);
virtual ~PMusrWizDefaultXMLParser() {}
virtual bool isValid() { return fValid; }
private:
enum EKeyWords {eEmpty, eInstitute, eInstrument, eFitType};
bool parse(QIODevice *device);
bool startDocument();
bool startElement(const QString&, const QString&, const QString& ,
const QXmlAttributes& );
bool endElement( const QString&, const QString&, const QString& );
bool characters(const QString&);
bool startElement();
bool endElement();
bool characters();
bool endDocument();
bool warning( const QXmlParseException & exception );
bool error( const QXmlParseException & exception );
bool fatalError( const QXmlParseException & exception );
QXmlStreamReader fXml; ///< xml stream reader object
bool fValid; ///< flag showing if XML read has been successful
EKeyWords fKeyWord; ///< key word tag to know how to handle the content
PAdmin *fAdmin; ///< a pointer to the main administration class object

View File

@ -38,6 +38,7 @@
#include <QDir>
#include <QProcessEnvironment>
#include <QSysInfo>
#include <QIODevice>
#include "musrfit-info.h"
#include "PAdmin.h"
@ -48,12 +49,60 @@
/**
* <p>XML Parser class for the musredit administration file.
*
* \param fln file name of the musredit startup xml-file
* \param admin pointer to an admin class instance.
*/
PAdminXMLParser::PAdminXMLParser(PAdmin *admin) : fAdmin(admin)
PAdminXMLParser::PAdminXMLParser(const QString& fln, PAdmin *admin) : fAdmin(admin)
{
fValid = false;
fKeyWord = eEmpty;
fFunc = false;
QFile file(fln);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// warning and create default - STILL MISSING
}
fValid = parse(&file);
}
//--------------------------------------------------------------------------
/**
* <p>parse the musredit startup xml-file.
*
* \param device QFile object of the musredit startup xml-file
*
* @return true on success, false otherwise
*/
bool PAdminXMLParser::parse(QIODevice *device)
{
fXml.setDevice(device);
bool expectChars = false;
while (!fXml.atEnd()) {
fXml.readNext();
if (fXml.isStartDocument()) {
startDocument();
} else if (fXml.isStartElement()) {
startElement();
expectChars = true;
} else if (fXml.isCharacters() && expectChars) {
characters();
} else if (fXml.isEndElement()) {
endElement();
expectChars = false;
} else if (fXml.isEndDocument()) {
endDocument();
}
}
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
return true;
}
//--------------------------------------------------------------------------
@ -62,6 +111,7 @@ PAdminXMLParser::PAdminXMLParser(PAdmin *admin) : fAdmin(admin)
*/
bool PAdminXMLParser::startDocument()
{
// nothing to be done here for now
return true;
}
@ -69,13 +119,11 @@ bool PAdminXMLParser::startDocument()
/**
* <p>Routine called when a new XML tag is found. Here it is used
* to set a tag for filtering afterwards the content.
*
* \param qName name of the XML tag.
*/
bool PAdminXMLParser::startElement( const QString&, const QString&,
const QString& qName,
const QXmlAttributes& )
bool PAdminXMLParser::startElement()
{
QStringRef qName = fXml.name();
if (qName == "timeout") {
fKeyWord = eTimeout;
} else if (qName == "font_name") {
@ -196,13 +244,13 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
* <p>Routine called when the end XML tag is found. It is used to
* put the filtering tag to 'empty'. It also resets the fFunc flag in case
* the entry was a theory function.
*
* \param qName name of the element.
*/
bool PAdminXMLParser::endElement( const QString&, const QString&, const QString &qName )
bool PAdminXMLParser::endElement()
{
fKeyWord = eEmpty;
QStringRef qName = fXml.name();
if (qName == "func") {
fFunc = false;
fAdmin->addTheoryItem(fTheoryItem);
@ -215,11 +263,13 @@ bool PAdminXMLParser::endElement( const QString&, const QString&, const QString
/**
* <p>This routine delivers the content of an XML tag. It fills the
* content into the load data structure.
*
* \param str keeps the content of the XML tag.
*/
bool PAdminXMLParser::characters(const QString& str)
bool PAdminXMLParser::characters()
{
QString str = *fXml.text().string();
if (str.isEmpty())
return true;
QString help;
bool flag, ok;
int ival;
@ -512,67 +562,90 @@ bool PAdminXMLParser::endDocument()
fAdmin->setTheoFuncPixmapPath(str);
}
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report XML warnings.
*
* \param exception holds the information of the XML warning
*/
bool PAdminXMLParser::warning( const QXmlParseException & exception )
{
QString msg;
msg = QString("**WARNING** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**WARNING MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
//as35 dump admin - only for debugging
//as35 dump();
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report recoverable XML errors.
*
* \param exception holds the information of the XML recoverable errors.
* <p>Dumps the content of the admin class. For debugging purposes only.
*/
bool PAdminXMLParser::error( const QXmlParseException & exception )
void PAdminXMLParser::dump()
{
QString msg;
msg = QString("**ERROR** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report fatal XML errors.
*
* \param exception holds the information of the XML fatal errors.
*/
bool PAdminXMLParser::fatalError( const QXmlParseException & exception )
{
QString msg;
msg = QString("**FATAL ERROR** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
std::cout << "debug> +++++++++++++++++++++++" << std::endl;
std::cout << "debug> general:" << std::endl;
std::cout << "debug> exec_path : " << fAdmin->getExecPath().toLatin1().data() << std::endl;
std::cout << "debug> default_save_path : " << fAdmin->getDefaultSavePath().toLatin1().data() << std::endl;
std::cout << "debug> timeout : " << fAdmin->getTimeout() << std::endl;
std::cout << "debug> keep_minuit2_output : " << fAdmin->getKeepMinuit2OutputFlag() << std::endl;
std::cout << "debug> dump_ascii : " << fAdmin->getDumpAsciiFlag() << std::endl;
std::cout << "debug> dump_root : " << fAdmin->getDumpRootFlag() << std::endl;
std::cout << "debug> title_from_data_file : " << fAdmin->getTitleFromDataFileFlag() << std::endl;
std::cout << "debug> chisq_per_run_block : " << fAdmin->getChisqPerRunBlockFlag() << std::endl;
std::cout << "debug> estimate_n0 : " << fAdmin->getEstimateN0Flag() << std::endl;
std::cout << "debug> musrview_show_fourier : " << fAdmin->getMusrviewShowFourierFlag() << std::endl;
std::cout << "debug> musrview_show_avg : " << fAdmin->getMusrviewShowAvgFlag() << std::endl;
std::cout << "debug> enable_musrt0 : " << fAdmin->getEnableMusrT0Flag() << std::endl;
std::cout << "debug> dark_theme_icons_menu : " << fAdmin->getDarkThemeIconsMenuFlag() << std::endl;
std::cout << "debug> dark_theme_icons_toolbar : " << fAdmin->getDarkThemeIconsToolbarFlag() << std::endl;
std::cout << "debug> +++++++++++++++++++++++" << std::endl;
std::cout << "debug> recent_files:" << std::endl;
for (int i=0; i<fAdmin->getNumRecentFiles(); i++) {
std::cout << "debug> recent_file " << i << ":" << fAdmin->getRecentFile(i).toLatin1().data() << std::endl;
}
std::cout << "debug> +++++++++++++++++++++++" << std::endl;
std::cout << "debug> help_section:" << std::endl;
std::cout << "debug> musr_web_main : " << fAdmin->getHelpUrl("main").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_title : " << fAdmin->getHelpUrl("title").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_parameters : " << fAdmin->getHelpUrl("parameters").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_theory : " << fAdmin->getHelpUrl("theory").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_functions : " << fAdmin->getHelpUrl("functions").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_run : " << fAdmin->getHelpUrl("run").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_command : " << fAdmin->getHelpUrl("command").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_fourier : " << fAdmin->getHelpUrl("fourier").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_plot : " << fAdmin->getHelpUrl("plot").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_statistic : " << fAdmin->getHelpUrl("statistic").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_msr2data : " << fAdmin->getHelpUrl("msr2data").toLatin1().data() << std::endl;
std::cout << "debug> musr_web_musrFT : " << fAdmin->getHelpUrl("musrFT").toLatin1().data() << std::endl;
std::cout << "debug> +++++++++++++++++++++++" << std::endl;
std::cout << "debug> font_section:" << std::endl;
std::cout << "debug> font_name : " << fAdmin->getFontName().toLatin1().data() << std::endl;
std::cout << "debug> font_size : " << fAdmin->getFontSize() << std::endl;
std::cout << "debug> +++++++++++++++++++++++" << std::endl;
std::cout << "debug> msr_file_defaults:" << std::endl;
std::cout << "debug> beamline : " << fAdmin->getBeamline().toLatin1().data() << std::endl;
std::cout << "debug> institute : " << fAdmin->getInstitute().toLatin1().data() << std::endl;
std::cout << "debug> file_format : " << fAdmin->getFileFormat().toLatin1().data() << std::endl;
std::cout << "debug> lifetime_correction : " << fAdmin->getLifetimeCorrectionFlag() << std::endl;
std::cout << "debug> +++++++++++++++++++++++" << std::endl;
std::cout << "debug> msr2data_defaults:" << std::endl;
std::cout << "debug> chain_fit : " << fAdmin->getMsr2DataParam().chainFit << std::endl;
std::cout << "debug> write_data_header : " << fAdmin->getMsr2DataParam().writeDbHeader << std::endl;
std::cout << "debug> ignore_data_header_info : " << fAdmin->getMsr2DataParam().ignoreDataHeaderInfo << std::endl;
std::cout << "debug> keep_minuit2_output : " << fAdmin->getMsr2DataParam().keepMinuit2Output << std::endl;
std::cout << "debug> write_column_data : " << fAdmin->getMsr2DataParam().writeColumnData << std::endl;
std::cout << "debug> recreate_data_file : " << fAdmin->getMsr2DataParam().recreateDbFile << std::endl;
std::cout << "debug> open_file_after_fitting : " << fAdmin->getMsr2DataParam().openFilesAfterFitting << std::endl;
std::cout << "debug> create_msr_file_only : " << fAdmin->getMsr2DataParam().createMsrFileOnly << std::endl;
std::cout << "debug> fit_only : " << fAdmin->getMsr2DataParam().fitOnly << std::endl;
std::cout << "debug> global : " << fAdmin->getMsr2DataParam().global << std::endl;
std::cout << "debug> global_plus : " << fAdmin->getMsr2DataParam().globalPlus << std::endl;
std::cout << "debug> +++++++++++++++++++++++" << std::endl;
std::cout << "debug> theory_functions:" << std::endl;
std::cout << "debug> func_pixmap_path : " << fAdmin->getTheoFuncPixmapPath().toLatin1().data() << std::endl;
std::cout << "debug> #theory : " << fAdmin->getTheoryCounts() << std::endl;
PTheory *theo;
for (unsigned int i=0; i<fAdmin->getTheoryCounts(); i++) {
theo = fAdmin->getTheoryItem(i);
std::cout << "debug> -------" << std::endl;
std::cout << "debug> name : " << theo->name.toLatin1().data() << std::endl;
std::cout << "debug> comment : " << theo->comment.toLatin1().data() << std::endl;
std::cout << "debug> label : " << theo->label.toLatin1().data() << std::endl;
std::cout << "debug> pixmapName : " << theo->pixmapName.toLatin1().data() << std::endl;
std::cout << "debug> params : " << theo->params << std::endl;
}
}
//--------------------------------------------------------------------------
@ -700,6 +773,34 @@ PAdmin::PAdmin() : QObject()
fPrefPathName = pathFln;
loadPrefs(fPrefPathName);
// make sure that musrfit, musrview, etc are found under the fExecPath provided
QString str = fExecPath + "/musrfit";
QFileInfo info(str);
if (info.exists()) {
if (!info.isExecutable())
QMessageBox::critical(0, "ERROR", "musrfit found but not recognized as executable.\nPlease check!");
} else {
QMessageBox::critical(0, "ERROR", "musrfit not found.\nHave you set the necessary system variables properly?\nPlease check the manual.\nBefore you can use musrfit, this needs to be fixed.");
}
// check if system variables are set properly
bool sysVarMissing = false;
QString msg("Missing System Variables:\n");
path = procEnv.value("ROOTSYS", "");
if (path.isEmpty()) {
msg += "> ROOTSYS\n";
sysVarMissing = true;
}
path = procEnv.value("MUSRFITPATH", "");
if (path.isEmpty()) {
msg += "> MUSRFITPATH\n";
sysVarMissing = true;
}
if (sysVarMissing) {
msg += "Please set this/these system variables.";
QMessageBox::warning(0, "WARNING", msg);
}
}
//--------------------------------------------------------------------------
@ -776,20 +877,15 @@ void PAdmin::setHelpUrl(const QString tag, const QString url)
int PAdmin::loadPrefs(QString fln)
{
if (QFile::exists(fln)) { // administration file present
PAdminXMLParser handler(this);
QFile xmlFile(fln);
QXmlInputSource source( &xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
reader.setErrorHandler( &handler );
if (!reader.parse( source )) {
QMessageBox::critical(0, "ERROR",
PAdminXMLParser handler(fln, this);
if (!handler.isValid()) {
QMessageBox::critical(0, "**ERROR**",
"Error parsing musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return 0;
}
} else {
QMessageBox::critical(0, "ERROR",
QMessageBox::critical(0, "**ERROR**",
"Couldn't find the musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return 0;

View File

@ -34,7 +34,7 @@
#include <QVector>
#include <QMap>
#include <QPixmap>
#include <QtXml>
#include <QXmlStreamReader>
#include <musredit.h>
@ -61,12 +61,14 @@ typedef struct {
* necessary informations about executable pathes, online help informations,
* default font sizes, etc.
*/
class PAdminXMLParser : public QXmlDefaultHandler
class PAdminXMLParser
{
public:
PAdminXMLParser(PAdmin*);
PAdminXMLParser(const QString &fln, PAdmin*);
virtual ~PAdminXMLParser() {}
virtual bool isValid() { return fValid; }
private:
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0,
@ -80,24 +82,23 @@ class PAdminXMLParser : public QXmlDefaultHandler
eChainFit, eWriteDataHeader, eIgnoreDataHeaderInfo, eWriteColumnData,
eRecreateDataFile, eOpenFileAfterFitting, eCreateMsrFileOnly, eFitOnly, eGlobal, eGlobalPlus};
bool parse(QIODevice *device);
bool startDocument();
bool startElement( const QString&, const QString&, const QString& ,
const QXmlAttributes& );
bool endElement( const QString&, const QString&, const QString& );
bool characters(const QString&);
bool startElement();
bool endElement();
bool characters();
bool endDocument();
bool warning( const QXmlParseException & exception );
bool error( const QXmlParseException & exception );
bool fatalError( const QXmlParseException & exception );
void dump();
QString expandPath(const QString&);
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
bool fFunc; ///< flag needed to indicate that a new theory function is found
PTheory fTheoryItem; ///< holding the informations necessary for a theory item
PAdmin *fAdmin; ///< a pointer to the main administration class object
QXmlStreamReader fXml; ///< xml stream reader object
bool fValid; ///< flag showing if XML read has been successful
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
bool fFunc; ///< flag needed to indicate that a new theory function is found
PTheory fTheoryItem; ///< holding the informations necessary for a theory item
PAdmin *fAdmin; ///< a pointer to the main administration class object
};
//---------------------------------------------------------------------------

View File

@ -27,21 +27,76 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QString>
#include <QStringRef>
#include <QMessageBox>
#include <QFileDialog>
#include <QListWidgetItem>
#include <QIODevice>
#include <QFile>
#include <QProcessEnvironment>
#include <QTextStream>
#include "PChangeDefaultPathsDialog.h"
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/**
* @brief PDefaultPathsXMLParser::PDefaultPathsXMLParser
* <p>XML Parser class for the musrfit administration file.
*
* \param fln file name of the musredit startup xml-file
* @param defaultPaths
*/
PDefaultPathsXMLParser::PDefaultPathsXMLParser(PDefaultPaths *defaultPaths) :
PDefaultPathsXMLParser::PDefaultPathsXMLParser(const QString& fln, PDefaultPaths *defaultPaths) :
fDefaultPaths(defaultPaths)
{
fValid = false;
fKeyWord = eEmpty;
QFile file(fln);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// warning and create default - STILL MISSING
}
fValid = parse(&file);
}
//--------------------------------------------------------------------------
/**
* <p>parse the musrfit startup xml-file.
*
* \param device QFile object of the musrfit startup xml-file
*
* @return true on success, false otherwise
*/
bool PDefaultPathsXMLParser::parse(QIODevice *device)
{
fXml.setDevice(device);
bool expectChars = false;
while (!fXml.atEnd()) {
fXml.readNext();
if (fXml.isStartDocument()) {
startDocument();
} else if (fXml.isStartElement()) {
startElement();
expectChars = true;
} else if (fXml.isCharacters() && expectChars) {
characters();
} else if (fXml.isEndElement()) {
endElement();
expectChars = false;
} else if (fXml.isEndDocument()) {
endDocument();
}
}
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
return true;
}
//--------------------------------------------------------------------------
@ -50,6 +105,7 @@ PDefaultPathsXMLParser::PDefaultPathsXMLParser(PDefaultPaths *defaultPaths) :
*/
bool PDefaultPathsXMLParser::startDocument()
{
// nothing to be done here for now
return true;
}
@ -57,13 +113,11 @@ bool PDefaultPathsXMLParser::startDocument()
/**
* <p>Routine called when a new XML tag is found. Here it is used
* to set a tag for filtering afterwards the content.
*
* \param qName name of the XML tag.
*/
bool PDefaultPathsXMLParser::startElement( const QString&, const QString&,
const QString& qName,
const QXmlAttributes& )
bool PDefaultPathsXMLParser::startElement()
{
QStringRef qName = fXml.name();
if (qName == "data_path") {
fKeyWord = eDataPath;
}
@ -75,10 +129,8 @@ bool PDefaultPathsXMLParser::startElement( const QString&, const QString&,
/**
* <p>Routine called when the end XML tag is found. It is used to
* put the filtering tag to 'empty'.
*
* \param qName name of the element.
*/
bool PDefaultPathsXMLParser::endElement( const QString&, const QString&, const QString & )
bool PDefaultPathsXMLParser::endElement()
{
fKeyWord = eEmpty;
@ -89,11 +141,13 @@ bool PDefaultPathsXMLParser::endElement( const QString&, const QString&, const Q
/**
* <p>This routine delivers the content of an XML tag. It fills the
* content into the load data structure.
*
* \param str keeps the content of the XML tag.
*/
bool PDefaultPathsXMLParser::characters(const QString& str)
bool PDefaultPathsXMLParser::characters()
{
QString str = *fXml.text().string();
if (str.isEmpty())
return true;
switch (fKeyWord) {
case eDataPath:
fDefaultPaths->appendDefaultPath(str);
@ -115,67 +169,10 @@ bool PDefaultPathsXMLParser::endDocument()
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report XML warnings.
*
* \param exception holds the information of the XML warning
*/
bool PDefaultPathsXMLParser::warning( const QXmlParseException & exception )
{
QString msg;
msg = QString("**WARNING** while parsing musrfit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**WARNING MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report recoverable XML errors.
*
* \param exception holds the information of the XML recoverable errors.
*/
bool PDefaultPathsXMLParser::error( const QXmlParseException & exception )
{
QString msg;
msg = QString("**ERROR** while parsing musrfit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Report fatal XML errors.
*
* \param exception holds the information of the XML fatal errors.
*/
bool PDefaultPathsXMLParser::fatalError( const QXmlParseException & exception )
{
QString msg;
msg = QString("**FATAL ERROR** while parsing musrfit_startup.xml in line no %1\n").arg(exception.lineNumber());
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
qWarning() << endl << msg << endl;
QMessageBox::critical(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return true;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/**
* @brief PDefaultPaths::PDefaultPaths
*/
PDefaultPaths::PDefaultPaths() : QObject()
{
fValid = true;
@ -204,13 +201,8 @@ PDefaultPaths::PDefaultPaths() : QObject()
fPrefPathName = pathFln;
// read musrfit_startup.xml and extract default data file search paths
PDefaultPathsXMLParser handler(this);
QFile xmlFile(fPrefPathName);
QXmlInputSource source( &xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( &handler );
reader.setErrorHandler( &handler );
if (!reader.parse( source )) {
PDefaultPathsXMLParser handler(fPrefPathName, this);
if (!handler.isValid()) {
fValid = false;
QMessageBox::critical(0, "ERROR",
"Error parsing musrfit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",

View File

@ -32,36 +32,36 @@
#include <QDialog>
#include <QMessageBox>
#include <QtXml>
#include <QXmlStreamReader>
#include <QIODevice>
#include "ui_PChangeDefaultPathsDialog.h"
class PDefaultPaths;
//---------------------------------------------------------------------------
class PDefaultPathsXMLParser : public QXmlDefaultHandler
class PDefaultPathsXMLParser
{
public:
PDefaultPathsXMLParser(PDefaultPaths *defaultPaths);
PDefaultPathsXMLParser(const QString &fln, PDefaultPaths *defaultPaths);
virtual ~PDefaultPathsXMLParser() {}
virtual bool isValid() { return fValid; }
private:
enum EAdminKeyWords {eEmpty, eDataPath};
bool parse(QIODevice *device);
bool startDocument();
bool startElement( const QString&, const QString&, const QString& ,
const QXmlAttributes& );
bool endElement( const QString&, const QString&, const QString& );
bool characters(const QString&);
bool startElement();
bool endElement();
bool characters();
bool endDocument();
bool warning( const QXmlParseException & exception );
bool error( const QXmlParseException & exception );
bool fatalError( const QXmlParseException & exception );
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
PDefaultPaths *fDefaultPaths; ///< keeps the default search paths for the data files
QXmlStreamReader fXml; ///< xml stream reader object
bool fValid; ///< flag showing if XML read has been successful
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
PDefaultPaths *fDefaultPaths; ///< keeps the default search paths for the data files
};
//---------------------------------------------------------------------------