libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
uimonitortextpercent.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/uimonitor/uimonitortextpercent.cpp
3 * \date 25/9/2021
4 * \author Olivier Langella
5 * \brief simle text monitor implementation of the User Interface Monitor
6 *displaying percent progression
7 **/
8
9/*******************************************************************************
10 * Copyright (c) 2021 Olivier Langella
11 *<Olivier.Langella@universite-paris-saclay.fr>.
12 *
13 * This file is part of the PAPPSOms++ library.
14 *
15 * PAPPSOms++ is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * PAPPSOms++ is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
27 *
28 ******************************************************************************/
29
31#include <QDebug>
32
33using namespace pappso;
34
36 : UiMonitorText(output_stream)
37{
38 m_unit = -1;
39 m_totalSteps = 1;
40}
41
45
46
47void
48pappso::UiMonitorTextPercent::setTotalSteps(std::size_t total_number_of_steps)
49{
50 if(m_count > 0)
51 {
52
53 m_outputStream << Qt::endl;
54 m_outputStream.flush();
55 }
56 UiMonitorText::setTotalSteps(total_number_of_steps);
57 m_unit = -1;
58 if(m_totalSteps == 0)
59 {
60 m_totalSteps = -1;
61 }
62}
63
64void
66{
67 m_count++;
69 {
70 int unit = (int)(((float)m_count / (float)m_totalSteps) * 10);
71 // qDebug() << unit;
72 if(unit > m_unit)
73 {
74 m_outputStream << (unit * 10) << "% ";
75 m_outputStream.flush();
76 m_unit = unit;
77 }
78 }
79}
virtual void count() override
count steps report when a step is computed in an algorithm
UiMonitorTextPercent(QTextStream &output_stream)
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...
QTextStream & m_outputStream
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...
UiMonitorText(QTextStream &output_stream)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39