mainwindow.cpp 3.55 KB
Newer Older
Edlira Nano's avatar
Edlira Nano committed
1
2
3
#include <QMenuBar>
#include <QFileDialog>
#include <QMessageBox>
Edlira Nano's avatar
Edlira Nano committed
4
#include <QDockWidget>
Edlira Nano's avatar
Edlira Nano committed
5

Edlira Nano's avatar
Edlira Nano committed
6
#include "mainwindow.h"
Edlira Nano's avatar
Edlira Nano committed
7
#include "xicSelectionWidget.h"
Edlira Nano's avatar
Edlira Nano committed
8
9
10
#include "xicProfile.h"
#include "xicPlot.h"

Edlira Nano's avatar
Edlira Nano committed
11

Edlira Nano's avatar
Edlira Nano committed
12

Edlira Nano's avatar
gui    
Edlira Nano committed
13
14
15
16
17
MainWindow::MainWindow(QWidget *parent)
  :
  QMainWindow(parent)
{

Edlira Nano's avatar
Edlira Nano committed
18
19
  _masschroq_gui = new MasschroqGui();
  
Edlira Nano's avatar
Edlira Nano committed
20
  // Central Widget
Edlira Nano's avatar
Edlira Nano committed
21
  
Edlira Nano's avatar
Edlira Nano committed
22
23
  _plot_area = new Plot(this);
  setCentralWidget(_plot_area);
Edlira Nano's avatar
Edlira Nano committed
24
25
26
27
28

  //_plot = new XicPlot(this);
  //const int margin = 4;
  //d_plot->setContentsMargins( margin, margin, margin, margin);
  //setCentralWidget(_plot);
Edlira Nano's avatar
Edlira Nano committed
29

Edlira Nano's avatar
Edlira Nano committed
30
31
32
33
34
35
  setWindowTitle(tr("MassChroQ GUI"));

  createActions();  
  createMenus();
  //createToolBars();
  //createStatusBar();
Edlira Nano's avatar
Edlira Nano committed
36
37
}

Edlira Nano's avatar
Edlira Nano committed
38

Edlira Nano's avatar
gui    
Edlira Nano committed
39
40
void 
MainWindow::createMenus() {
Edlira Nano's avatar
Edlira Nano committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  _fileMenu = menuBar()->addMenu(tr("&File"));
  _fileMenu->addAction(_loadMsrunAct);
  _fileMenu->addSeparator();
  _fileMenu->addAction(_quitAct);
  
  _toolsMenu = menuBar()->addMenu(tr("&Tools"));
  _toolsMenu->addAction(_extractXicAct);
  _toolsMenu->addAction(_applyFilterAct);
  
  menuBar()->addSeparator();
  
  _helpMenu = menuBar()->addMenu(tr("&Help"));
  _helpMenu->addAction(_aboutAct);
  
Edlira Nano's avatar
gui    
Edlira Nano committed
55
56
}

Edlira Nano's avatar
Edlira Nano committed
57
58
59
void 
MainWindow::createActions() {

Edlira Nano's avatar
Edlira Nano committed
60
61
62
63
64
65
66
67
68
69
70
71
72
  _loadMsrunAct = new QAction(tr("&Load MS-run"), this);
  _loadMsrunAct->setShortcuts(QKeySequence::Open);
  _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(QKeySequence(Qt::CTRL + Qt::Key_X));
  _extractXicAct->setStatusTip(tr("Select values vor XIC extraction"));
Edlira Nano's avatar
Edlira Nano committed
73
  connect(_extractXicAct, SIGNAL(triggered()), this, SLOT(extractXicWidget()));
Edlira Nano's avatar
Edlira Nano committed
74
75
76
77
78
79
80
81

  _applyFilterAct = new QAction(tr("&filter XIC"), this);
  _applyFilterAct->setShortcut(QKeySequence(tr("Ctrl+F")));
  _applyFilterAct->setStatusTip(tr("Select filter to apply on XIC"));
  connect(_applyFilterAct, SIGNAL(triggered()), this, SLOT(filterXic()));

  _aboutAct = new QAction(tr("&About"), this);
  _aboutAct->setStatusTip(tr("About MassChroQ GUI"));
Edlira Nano's avatar
Edlira Nano committed
82
  connect(_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
Edlira Nano's avatar
Edlira Nano committed
83
  
84
  
Edlira Nano's avatar
Edlira Nano committed
85
86
}

Edlira Nano's avatar
Edlira Nano committed
87
88
89
90
91
92
93
94
void
MainWindow::loadMsrun() {
  QString filename = QFileDialog::getOpenFileName(this, tr("Open Msrun File"), 
		     QString::null, 
		     tr("mzXML or mzML files (*.mzXML *.mzML)"));
  
  if (!filename.isEmpty()) {
    _current_msrun_file = filename; 
Edlira Nano's avatar
Edlira Nano committed
95
    _masschroq_gui->setMsRun(filename);
Edlira Nano's avatar
Edlira Nano committed
96
  }
Edlira Nano's avatar
Edlira Nano committed
97
  cout << "end loading" << endl;
Edlira Nano's avatar
Edlira Nano committed
98
99
}

Edlira Nano's avatar
Edlira Nano committed
100
void
Edlira Nano's avatar
Edlira Nano committed
101
MainWindow::extractXicWidget() {
Edlira Nano's avatar
Edlira Nano committed
102
103
104
105
  QDockWidget * dock = new QDockWidget(tr("XIC extraction"), this);
  XicSelectionWidget * xic = new XicSelectionWidget(dock);
  dock->setWidget(xic);
  addDockWidget(Qt::LeftDockWidgetArea, dock);
Edlira Nano's avatar
Edlira Nano committed
106
  connect(xic, SIGNAL(extract(XicSelectionWidget *)), this, SLOT(extractXic(XicSelectionWidget *)));
Edlira Nano's avatar
Edlira Nano committed
107
108
109
}

void
Edlira Nano's avatar
Edlira Nano committed
110
111
112
113
114
115
116
117
118
119
120
121
MainWindow::extractXic(XicSelectionWidget * xic_widget) {
  XicProfile * xic_profile = new XicProfile();
  connect(xic_profile, SIGNAL(created(XicProfile *)), this, SLOT(plotXic(XicProfile *)));
  _xic_profiles.push_back(xic_profile);
  _masschroq_gui->extractXicProfile(xic_profile, _current_msrun_file, xic_widget);
}


void
MainWindow::plotXic(XicProfile * xic_profile) {
  XicPlot * plot = new XicPlot("Original Xic", xic_profile);
  _plot_area->addPlot(plot);
Edlira Nano's avatar
Edlira Nano committed
122
123
124
125
126
127
128
129
130
131
132
133
134
135
}

void
MainWindow::filterXic() {
  
}


void MainWindow::about() {
  QMessageBox::about(this, tr("About MassChroQ"),
		     tr("This is <b>MassChroQ GUI</b> version beta."));
}