annotate base/ProgressPrinter.cpp @ 1394:9ef1cc26024c

Add Range01 normalisation method to ColumnOp. This is the normalisation that is actually used in the Colour 3D Plot layer historically when column normalisation is enabled (not Max1 after all).
author Chris Cannam
date Tue, 28 Feb 2017 14:04:16 +0000
parents f5cd33909744
children
rev   line source
Chris@392 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@392 2
Chris@392 3 /*
Chris@392 4 Sonic Visualiser
Chris@392 5 An audio file viewer and annotation editor.
Chris@392 6 Centre for Digital Music, Queen Mary, University of London.
Chris@392 7 This file copyright 2007 QMUL.
Chris@392 8
Chris@392 9 This program is free software; you can redistribute it and/or
Chris@392 10 modify it under the terms of the GNU General Public License as
Chris@392 11 published by the Free Software Foundation; either version 2 of the
Chris@392 12 License, or (at your option) any later version. See the file
Chris@392 13 COPYING included with this distribution for more information.
Chris@392 14 */
Chris@392 15
Chris@392 16 #include "ProgressPrinter.h"
Chris@392 17
Chris@392 18 #include <iostream>
Chris@392 19
Chris@843 20 #include "Debug.h"
Chris@843 21
Chris@392 22 ProgressPrinter::ProgressPrinter(QString message, QObject *parent) :
Chris@392 23 ProgressReporter(parent),
Chris@392 24 m_prefix(message),
Chris@439 25 m_lastProgress(0),
Chris@439 26 m_definite(true)
Chris@392 27 {
Chris@521 28 if (m_prefix.length() > 70) {
Chris@521 29 m_prefix = m_prefix.left(70) + "...";
Chris@521 30 }
Chris@392 31 }
Chris@392 32
Chris@392 33 ProgressPrinter::~ProgressPrinter()
Chris@392 34 {
Chris@392 35 if (m_lastProgress > 0 && m_lastProgress != 100) {
Chris@843 36 cerr << "\r\n";
Chris@392 37 }
Chris@843 38 // cerr << "(progress printer dtor)" << endl;
Chris@392 39 }
Chris@392 40
Chris@439 41 bool
Chris@439 42 ProgressPrinter::isDefinite() const
Chris@439 43 {
Chris@439 44 return m_definite;
Chris@439 45 }
Chris@439 46
Chris@439 47 void
Chris@439 48 ProgressPrinter::setDefinite(bool definite)
Chris@439 49 {
Chris@439 50 m_definite = definite;
Chris@439 51 }
Chris@439 52
Chris@392 53 void
Chris@393 54 ProgressPrinter::setMessage(QString message)
Chris@393 55 {
Chris@393 56 m_prefix = message;
Chris@624 57 if (m_prefix.length() > 70) {
Chris@624 58 m_prefix = m_prefix.left(70) + "...";
Chris@624 59 }
Chris@393 60 }
Chris@393 61
Chris@393 62 void
Chris@515 63 ProgressPrinter::done()
Chris@515 64 {
Chris@843 65 cerr << "\r"
Chris@844 66 << m_prefix
Chris@517 67 << (m_prefix == "" ? "" : " ")
Chris@843 68 << "Done" << endl;
Chris@515 69 }
Chris@515 70
Chris@515 71 void
Chris@392 72 ProgressPrinter::setProgress(int progress)
Chris@392 73 {
Chris@392 74 if (progress == m_lastProgress) return;
Chris@843 75 cerr << "\r"
Chris@844 76 << m_prefix
Chris@517 77 << (m_prefix == "" ? "" : " ");
Chris@517 78 if (m_definite) {
Chris@843 79 cerr << progress << "%";
Chris@517 80 } else {
Chris@843 81 cerr << "|/-\\"[progress % 4];
Chris@392 82 }
Chris@392 83 m_lastProgress = progress;
Chris@392 84 }
Chris@392 85