Commit d28717ed authored by Renne Thomas's avatar Renne Thomas
Browse files

Add MsRunStatisticsHandler with override bug

parent 216961a1
......@@ -22,14 +22,34 @@
*implementation
******************************************************************************/
#include <tuple>
#include "msidlistworkerstatus.h"
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/exception/exceptionnotfound.h>
#include <unistd.h>
#include "msidlistworkerthread.h"
#include <gui/lists/ms_identification_run_list_view/msidentificationtablemodel.h>
MsRunStatisticsHandler::MsRunStatisticsHandler():pappso::SpectrumCollectionHandlerInterface()
{
qDebug() << "OOOOOO test";
}
bool
MsRunStatisticsHandler::shouldStop()
{
qDebug() << "RRRRRR test";
QMutexLocker locker(&m_mutex);
return true;
}
void
MsRunStatisticsHandler::requireStop(bool stop)
{
QMutexLocker locker(&m_mutex);
m_stopRequired = stop;
}
MsIdListWorkerStatus::MsIdListWorkerStatus(MsIdListWorkerThread *worker)
{
connect(this,
......@@ -41,10 +61,16 @@ MsIdListWorkerStatus::MsIdListWorkerStatus(MsIdListWorkerThread *worker)
&MsIdListWorkerThread::MsNumberComputing,
this,
&MsIdListWorkerStatus::setRunningIdData);
mpa_currentHandler = nullptr;
}
MsIdListWorkerStatus::~MsIdListWorkerStatus()
{
if(mpa_currentHandler != nullptr)
{
delete mpa_currentHandler;
}
}
WorkerStatus
......@@ -66,8 +92,19 @@ MsIdListWorkerStatus::getStatus(
}
else
{
qDebug();
if(mpa_currentHandler != nullptr)
{
qDebug();
delete mpa_currentHandler;
}
qDebug();
mpa_currentHandler = new MsRunStatisticsHandler();
qDebug() << "DDDDDDDDDDDDDD" << mpa_currentHandler->shouldStop();
emit computeMsNumber(identificationDataSource);
m_list_idSources.push_back(identificationDataSource);
return WorkerStatus::Waiting;
}
return WorkerStatus::Waiting;
......
......@@ -28,6 +28,36 @@
#include "core/msrun.h"
#include "core/identification_sources/identificationdatasource.h"
class MsRunStatisticsHandler : public pappso::SpectrumCollectionHandlerInterface
{
public:
MsRunStatisticsHandler() ;
virtual ~MsRunStatisticsHandler() {};
virtual void setQualifiedMassSpectrum(
const pappso::QualifiedMassSpectrum &qspectrum) override;
virtual bool needPeakList() const override;
unsigned long getMsLevelCount(unsigned int ms_level) const;
pappso::pappso_double getMsLevelTic(unsigned int ms_level) const;
unsigned long getTotalCount() const;
virtual bool
shouldStop() override ;
void
requireStop(bool stop);
private:
std::vector<unsigned long> _count_ms_level_spectrum;
std::vector<pappso::pappso_double> _tic_ms_level_spectrum;
QMutex m_mutex;
bool m_stopRequired = true;
};
class MsIdentificationTableModel;
enum class WorkerStatus : std::int8_t
......@@ -61,4 +91,5 @@ class MsIdListWorkerStatus : public QObject
private:
std::vector<IdentificationDataSourceSp> m_list_idSources;
pappso::SpectrumCollectionHandlerInterface *mpa_currentHandler = nullptr;
};
......@@ -30,6 +30,7 @@
#include "msidlistworkerthread.h"
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/exception/exceptionnotfound.h>
#include "msidlistworkerstatus.h"
MsIdListWorkerThread::MsIdListWorkerThread()
{
......@@ -43,12 +44,15 @@ void
MsIdListWorkerThread::doComputeMsNumber(
IdentificationDataSourceSp identificationDataSource)
{
emit MsNumberComputing(identificationDataSource);
// while(currentHandler->get(). == false)
// {
emit MsNumberComputing(identificationDataSource);
if(identificationDataSource->getMsRunSp()->findMsRunFile())
{
identificationDataSource->getMsRunSp()->checkMsRunStatistics();
}
identificationDataSource->getMsRunSp()->freeMsRunReaderSp();
emit MsNumberComputed();
if(identificationDataSource->getMsRunSp()->findMsRunFile())
{
identificationDataSource->getMsRunSp()->checkMsRunStatistics();
}
identificationDataSource->getMsRunSp()->freeMsRunReaderSp();
emit MsNumberComputed();
// }
}
......@@ -29,6 +29,7 @@
#include "msidentificationlistwindow.h"
#include "ms_identification_worker/msidlistworkerthread.h"
#include "../../../utils/identificationdatasourcestore.h"
#include <QSvgRenderer>
MsIdentificationTableModel::MsIdentificationTableModel(
MsIdentificationListWindow *ms_id_list_window)
......@@ -40,7 +41,11 @@ MsIdentificationTableModel::MsIdentificationTableModel(
p_worker->moveToThread(&m_ms_id_list_thread);
m_ms_id_list_thread.start();
msp_workerStatus = std::make_shared<MsIdListWorkerStatus>(p_worker);
mp_movie = new QMovie("/home/trenne/Documents/graph/iconWait.gif");
mp_movie->start();
mp_movie->setScaledSize(QSize(20, 20));
connect(p_worker,
&MsIdListWorkerThread::MsNumberComputed,
this,
......@@ -49,12 +54,17 @@ MsIdentificationTableModel::MsIdentificationTableModel(
&MsIdentificationTableModel::ComputeMsNumber,
p_worker,
&MsIdListWorkerThread::doComputeMsNumber);
connect(mp_movie,
&QMovie::frameChanged,
this,
&MsIdentificationTableModel::onMsIdentificationDataChanged);
}
MsIdentificationTableModel::~MsIdentificationTableModel()
{
m_ms_id_list_thread.quit();
m_ms_id_list_thread.wait();
delete mp_movie;
}
void
......@@ -347,7 +357,7 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
if(temp == WorkerStatus::Running)
{
return QVariant("Running");
return QVariant("");
}
else if(temp == WorkerStatus::Waiting)
{
......@@ -377,12 +387,16 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
if(temp == WorkerStatus::Running)
{
return QVariant("Running");
return QVariant("");
}
else
else if(temp == WorkerStatus::Waiting)
{
return QVariant("Wait");
}
else
{
return QVariant("Error");
}
}
else
{
......@@ -404,10 +418,48 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
->getFileName());
}
return QVariant();
case Qt::DecorationRole:
if(col == (std::int8_t)msIdentificationListColumn::nb_ms_1)
{
QVariant nb_ms1 =
m_identificationDataSourceSpList.at(row)
->getMsRunSp()
->getMsRunStatistics(MsRunStatistics::total_spectra_ms1);
if(nb_ms1.isNull())
{
WorkerStatus temp = msp_workerStatus.get()->getStatus(
m_identificationDataSourceSpList.at(row));
if(temp == WorkerStatus::Running)
{
return mp_movie->currentImage();
}
}
}
if(col == (std::int8_t)msIdentificationListColumn::nb_ms_2)
{
QVariant nb_ms1 =
m_identificationDataSourceSpList.at(row)
->getMsRunSp()
->getMsRunStatistics(MsRunStatistics::total_spectra_ms2);
if(nb_ms1.isNull())
{
WorkerStatus temp = msp_workerStatus.get()->getStatus(
m_identificationDataSourceSpList.at(row));
if(temp == WorkerStatus::Running)
{
return mp_movie->currentImage();
}
}
}
return QVariant();
}
return QVariant();
}
void
MsIdentificationTableModel::onMsIdentificationDataChanged()
{
......
......@@ -28,6 +28,7 @@
#include <QThread>
#include <memory>
#include "ms_identification_worker/msidlistworkerstatus.h"
#include <QMovie>
/** \def msIdentificationListColumn list of available fields to display in ms
......@@ -67,7 +68,9 @@ class MsIdentificationTableModel : public QAbstractTableModel
headerData(int section, Qt::Orientation orientation, int role) const override;
virtual QVariant data(const QModelIndex &index,
int role = Qt::DisplayRole) const override;
void paint(QPainter* painter, IdentificationDataSourceSp identificationDataSource,
const QModelIndex& index) const;
static const QString getTitle(msIdentificationListColumn column);
static const QString getDescription(msIdentificationListColumn column);
static const QString getTitle(std::int8_t column);
......@@ -97,4 +100,5 @@ class MsIdentificationTableModel : public QAbstractTableModel
MsIdentificationListWindow *m_ms_id_list_window;
QThread m_ms_id_list_thread;
std::shared_ptr<MsIdListWorkerStatus> msp_workerStatus = nullptr;
QMovie *mp_movie;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment