Commit 7e35393f authored by Edlira Nano's avatar Edlira Nano
Browse files

clean-up post matching release

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2262 e4b6dbb4-9209-464b-83f7-6257456c460c
parent cae44263
/**
* \file filterBackgroundWidget.cpp
* \date November 24, 2011
* \author Edlira Nano
*/
#include "filterBackgroundWidget.h"
#include <QtGui>
FilterBackgroundWidget::FilterBackgroundWidget(QWidget * parent)
:
QWidget(parent)
{
create_parameters();
QPushButton * filterButton = new QPushButton(tr("&Filter"));
filterButton->setDefault(true);
_button_box = new QDialogButtonBox(Qt::Vertical);
_button_box->addButton(filterButton, QDialogButtonBox::AcceptRole);
_button_box->addButton(QDialogButtonBox::Cancel);
connect(_button_box, SIGNAL(accepted()), this, SLOT(filterXic()));
connect(_button_box, SIGNAL(rejected()), this, SLOT(cancel()));
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addWidget(_median_group);
mainLayout->addWidget(_minmax_group);
mainLayout->addWidget(_button_box);
setLayout(mainLayout);
setWindowTitle(tr("Background noise filter"));
}
FilterBackgroundWidget::~FilterBackgroundWidget() {
}
void
FilterBackgroundWidget::create_parameters() {
_median_group = new QGroupBox;
QGridLayout *layout1 = new QGridLayout;
QLabel * median_label = new QLabel("Median filtering half window");
QSpinBox * median_box = new QSpinBox;
connect(median_box, SIGNAL(valueChanged(int)),
this, SLOT(setMedianHalfWindow(int)));
median_box->setMaximum(20);
median_box->setWrapping(true);
median_box->setSingleStep(1);
median_box->setValue(5);
layout1->addWidget(median_label, 0, 0);
layout1->addWidget(median_box, 0, 1);
_median_group->setLayout(layout1);
_minmax_group = new QGroupBox;
QGridLayout *layout2 = new QGridLayout;
QLabel * minmax_label = new QLabel("MinMax filtering half window");
QSpinBox * minmax_box = new QSpinBox;
connect(minmax_box, SIGNAL(valueChanged(int)),
this, SLOT(setMinMaxHalfWindow(int)));
minmax_box->setMaximum(20);
minmax_box->setWrapping(true);
minmax_box->setSingleStep(1);
median_box->setValue(5);
layout2->addWidget(minmax_label, 1, 0);
layout2->addWidget(minmax_box, 1, 1);
_minmax_group->setLayout(layout2);
}
void
FilterBackgroundWidget::setMedianHalfWindow(int i) {
_median_half_window = i;
}
void
FilterBackgroundWidget::setMinMaxHalfWindow(int i) {
_min_max_half_window = i;
}
const int
FilterBackgroundWidget::getMedianHalfWindow() const {
return _median_half_window;
}
const int
FilterBackgroundWidget::getMinMaxHalfWindow() const {
return _min_max_half_window;
}
void
FilterBackgroundWidget::filterXic() {
emit filter(this);
}
void
FilterBackgroundWidget::cancel() {
this->close();
this->deleteLater();
}
/*
*
* MassChroQ: Mass Chromatogram Quantification software.
* Copyright (C) 2010 Olivier Langella, Edlira Nano, Benoit Valot, Michel Zivy.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file filterBackgroundWidget.h
* \date November 24, 2011
* \author Edlira Nano
*/
#ifndef FILTER_BACKGROUND_WIDGET_H_
#define FILTER_BACKGROUND_WIDGET_H_ 1
#include <QWidget>
#include "../mcq_types.h"
class QButtonGroup;
class QGroupBox;
class QDialogButtonBox;
class QAbstractButton;
class XicExtractionMethodBase;
/**
* \class FilterBackgroundWidget
* \brief Background noise removal XIC filter Widget
*
*
**/
class FilterBackgroundWidget : public QWidget {
Q_OBJECT
public :
FilterBackgroundWidget(QWidget * parent = 0);
virtual ~FilterBackgroundWidget();
const int getMedianHalfWindow() const;
const int getMinMaxHalfWindow() const;
private slots :
void setMedianHalfWindow(int i);
void setMinMaxHalfWindow(int i);
void filterXic();
void cancel();
signals :
void filter(FilterBackgroundWidget *);
protected :
int _median_half_window;
int _min_max_half_window;
private :
// void create_xic_type_group();
// void create_xic_range_group();
// void create_mz_group();
QGroupBox * _median_group;
QGroupBox * _minmax_group;
QDialogButtonBox * _button_box;
void create_parameters();
};
#endif /* FILTER_BACKGROUND_WIDGET_H_ */
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char ** argv) {
QApplication app(argc, argv);
MainWindow window;
window.show();
return app.exec();
}
/*
*
* MassChroQ: Mass Chromatogram Quantification software.
* Copyright (C) 2010 Olivier Langella, Edlira Nano, Benoit Valot, Michel Zivy.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file gui_types.h
* \date November 23, 2011
* \author Edlira Nano
* \brief This header contains all the type re-definitions and all
* the global variables definitions used in MassChroQ GUI.
*/
#ifndef _GUI_TYPES_H_
#define _GUI_TYPES_H_ 1
#include "plotStyle.h"
/*********** Global variables definitions*********************************/
const PlotStyle OriginalXicStyle(QPen(Qt::black));
const PlotStyle FilterBackgroundStyle(QPen(Qt::green));
const PlotStyle FilterSpikeStyle(QPen(Qt::blue));
#endif /* _GUI_TYPES_H_ */
#include <QMenuBar>
#include <QFileDialog>
#include <QMessageBox>
#include <QDockWidget>
#include <QStatusBar>
#include <QProgressDialog>
#include <QApplication>
#include <QTimer>
#include <QCloseEvent>
#include "mainwindow.h"
#include "xicSelectionWidget.h"
#include "xicProfile.h"
#include "xicPlot.h"
#include "../lib/filters/filter_background.h"
MainWindow::MainWindow(QWidget *parent)
:
QMainWindow(parent)
{
_masschroq_gui = new MasschroqGui(this);
// Central Widget
_plot_area = new Plot(this);
setCentralWidget(_plot_area);
createActions();
createMenus();
//createToolBars();
createStatusBar();
setWindowTitle(tr("MassChroQ GUI"));
// cannot resize the main window to less than 200x200
setMinimumSize(200, 200);
// size at creation is 480x320
resize(480, 320);
_msrun_loader_thread.setMaxProgress(4);
connect(&_msrun_loader_thread, SIGNAL(loadedMsrun(Msrun *)),
this, SLOT(doneLoading(Msrun *)));
}
void
MainWindow::createStatusBar() {
statusBar()->showMessage(tr("Ready"));
}
void
MainWindow::createMenus() {
_fileMenu = menuBar()->addMenu(tr("&File"));
_fileMenu->addAction(_loadMsrunAct);
_fileMenu->addSeparator();
_fileMenu->addAction(_quitAct);
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
_toolsMenu->addAction(_extractXicAct);
_fileMenu->addSeparator();
_filtersMenu = _toolsMenu->addMenu(tr("&Filter XIC"));
_filtersMenu->addAction(_filterBackgroundAct);
_filtersMenu->addAction(_filterSpikeAct);
_helpMenu = menuBar()->addMenu(tr("&Help"));
_helpMenu->addAction(_aboutAct);
}
void
MainWindow::createActions() {
_loadMsrunAct = new QAction(tr("&Load MS-run"), this);
_loadMsrunAct->setShortcut(tr("Ctrl+L"));
_loadMsrunAct->setStatusTip(tr("Load an MS-run file"));
connect(_loadMsrunAct, SIGNAL(triggered()), this, SLOT(loadMsrun()));
_quitAct = new QAction(tr("&Quit"), this);
_quitAct->setShortcuts(QKeySequence::Quit);
_quitAct->setStatusTip(tr("Quit MassChroQ GUI"));
connect(_quitAct, SIGNAL(triggered()), this, SLOT(close()));
_extractXicAct = new QAction(tr("&extract XIC"), this);
_extractXicAct->setShortcut(tr("Ctrl+X"));
_extractXicAct->setStatusTip(tr("Select values vor XIC extraction"));
connect(_extractXicAct, SIGNAL(triggered()), this, SLOT(extractXicWidget()));
_filterBackgroundAct = new QAction(tr("&Background filter"), this);
_filterBackgroundAct->setShortcut(tr("Ctrl+B"));
_filterBackgroundAct->setStatusTip(tr("Apply a backround noise removal filter to the XIC"));
connect(_filterBackgroundAct, SIGNAL(triggered()), this, SLOT(filterBackgroundWidget()));
_filterSpikeAct = new QAction(tr("&Spike filter"), this);
_filterSpikeAct->setShortcut(tr("Ctrl+S"));
_filterSpikeAct->setStatusTip(tr("Apply a spike removal filter to the XIC"));
connect(_filterSpikeAct, SIGNAL(triggered()), this, SLOT(filterSpikeWidget()));
_aboutAct = new QAction(tr("&About"), this);
_aboutAct->setStatusTip(tr("About MassChroQ GUI"));
connect(_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}
void
MainWindow::closeEvent(QCloseEvent * event) {
if (maybeSave()) {
discardCurrentMsrun();
event->accept();
} else {
event->ignore();
}
}
bool
MainWindow::maybeSave() {
QMessageBox::StandardButton ret;
ret = QMessageBox::warning(this, tr("MassChroQ GUI"),
tr("The xic plots have been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
if (ret == QMessageBox::Save)
return save();
else if (ret == QMessageBox::Cancel)
return false;
}
bool
MainWindow::save() {
return true;
}
void
MainWindow::loadMsrun() {
QString filename = QFileDialog::getOpenFileName(this, tr("Open Msrun File"),
QString::null,
tr("mzXML or mzML files (*.mzXML *.mzML)"));
if (!filename.isEmpty()) {
discardCurrentMsrun();
_current_msrun_file = filename;
QString progressTitle(QObject::tr("Loading '%1'...").arg(strippedFilename(filename)));
_runningBarr = new RunningBarr(this, &_msrun_loader_thread, progressTitle);
_runningBarr->setTimer();
// launch _msrun_loader_thread
_masschroq_gui->setMsRun(filename, &_msrun_loader_thread);
} else {
}
}
void
MainWindow::discardCurrentMsrun() {
_masschroq_gui->deleteMsrun(_current_msrun_file);
_current_msrun_file.clear();
}
void
MainWindow::doneLoading(Msrun * msrun) {
QString filename = (msrun->getXmlFileInfo()).filePath();
_masschroq_gui->addMsrun(filename, msrun);
QString sfilename = strippedFilename(filename);
this->statusBar()->showMessage(QObject::tr("MS run '%1' loaded").arg(sfilename), 4000);
this->setPlotAreaTitle(filename);
delete _runningBarr;
this->statusBar()->showMessage(QObject::tr("Current working MS run is '%1'").arg(sfilename));
}
void
MainWindow::extractXicWidget() {
QDockWidget * dock = new QDockWidget(tr("XIC extraction"), this);
addDockWidget(Qt::LeftDockWidgetArea, dock);
XicSelectionWidget * xic = new XicSelectionWidget(dock);
connect(xic, SIGNAL(extract(XicSelectionWidget *)), this, SLOT(extractXic(XicSelectionWidget *)));
dock->setWidget(xic);
}
void
MainWindow::extractXic(XicSelectionWidget * xic_widget) {
XicProfile * xic_profile = new XicProfile();
connect(xic_profile, SIGNAL(created(XicProfile *)), this, SLOT(plotNewXic(XicProfile *)));
// _xic_profiles.push_back(xic_profile);
_current_xic_profile = xic_profile;
_masschroq_gui->extractXicProfile(xic_profile, _current_msrun_file, xic_widget);
}
void
MainWindow::filterBackgroundWidget() {
QDockWidget * dock = new QDockWidget(tr("Background noise filter"), this);
addDockWidget(Qt::LeftDockWidgetArea, dock);
FilterBackgroundWidget * backgroundFilter = new FilterBackgroundWidget(dock);
connect(backgroundFilter, SIGNAL(filter(FilterBackgroundWidget *)),
this, SLOT(filterBackgroundXic(FilterBackgroundWidget *)));
dock->setWidget(backgroundFilter);
}
void
MainWindow::filterBackgroundXic(FilterBackgroundWidget * fback_widget) {
filterBackground * f_back = new filterBackground();
f_back->set_half_median_window_length(fback_widget->getMedianHalfWindow());
f_back->set_half_min_max_window_length(fback_widget->getMinMaxHalfWindow());
// _masschroq_gui->applyFilterToXicProfile(_current_xic_profile, f_back);
}
void
MainWindow::filterSpikeWidget() {
}
void
MainWindow::filterSpikeXic(/*FilterSpikeWidget * fspike_widget*/) {
}
void
MainWindow::plotNewXic(XicProfile * xic_profile) {
_plot_area->clear();
_plot_area->addPlot(xic_profile);
}
void MainWindow::about() {
QMessageBox::about(this, tr("About MassChroQ"),
tr("This is <b>MassChroQ GUI</b> version beta."));
}
void MainWindow::setPlotAreaTitle(const QString & filename) {
_plot_area->setWindowFilePath(filename);
QString title("Xic plots : ");
title.append(strippedFilename(filename));
_plot_area->setTitle(title);
}
QString
MainWindow::strippedFilename(const QString & fullFilename) {
return QFileInfo(fullFilename).fileName();
}
/*
*
* MassChroQ: Mass Chromatogram Quantification software.
* Copyright (C) 2010 Olivier Langella, Edlira Nano, Benoit Valot, Michel Zivy.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope thatx it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file mainwindow.h
* \date November 10, 2011
* \author Edlira Nano
*/
#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_ 1
#include <QMainWindow>
#include <QMenu>
#include <QToolBar>
#include <QAction>
#include "masschroq_gui.h"
#include "plot.h"
#include "runningBarr.h"
#include "msrunLoaderThread.h"
#include "filterBackgroundWidget.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget * parent = 0);
void setPlotAreaTitle(const QString & filename);
private slots:
void loadMsrun();
void extractXicWidget();
void extractXic(XicSelectionWidget * xic);
void plotNewXic(XicProfile * xic_profile);
void filterBackgroundWidget();
void filterBackgroundXic(FilterBackgroundWidget * fb);
void filterSpikeWidget();
void filterSpikeXic(/* FilterSpikeWidget *fs*/);
void about();
void doneLoading(Msrun * msrun);
protected:
void closeEvent(QCloseEvent *event);
private:
void createActions();
void createMenus();
void createStatusBar();
//void createDockWindows();
//void createToolbars();
bool maybeSave();
bool save();
void discardCurrentMsrun();
QString strippedFilename(const QString & fullFilename);
//QListWidget * filtersList;
//QListWidget * quantiItemsList;
Plot * _plot_area;
/// Menus
QMenu * _fileMenu;
QMenu * _toolsMenu;
QMenu * _filtersMenu;
QMenu * _helpMenu;
/// Menu actions
QAction * _loadMsrunAct;
QAction * _extractXicAct;
QAction * _filterBackgroundAct;
QAction * _filterSpikeAct;
QAction * _aboutAct;
QAction * _quitAct;
MasschroqGui * _masschroq_gui;
RunningBarr * _runningBarr;
MsrunLoaderThread _msrun_loader_thread;
QString _current_msrun_file;
// std::vector<XicProfile *> _xic_profiles;
XicProfile * _current_xic_profile;
};