1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// --------------------------------------------------------------------------
6
// OpenMS Mass Spectrometry Framework
7
// --------------------------------------------------------------------------
8
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
10
// This library is free software; you can redistribute it and/or
11
// modify it under the terms of the GNU Lesser General Public
12
// License as published by the Free Software Foundation; either
13
// version 2.1 of the License, or (at your option) any later version.
15
// This library is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
// Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public
21
// License along with this library; if not, write to the Free Software
22
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
// --------------------------------------------------------------------------
25
// $Maintainer: Timo Sachsenberg$
26
// $Authors: Timo Sachsenberg, Marc Sturm $
27
// --------------------------------------------------------------------------
29
#include <OpenMS/VISUAL/APPLICATIONS/TOPPViewBase.h>
31
#include <OpenMS/ANALYSIS/ID/IDMapper.h>
32
#include <OpenMS/CHEMISTRY/TheoreticalSpectrumGenerator.h>
33
#include <OpenMS/CHEMISTRY/AASequence.h>
34
#include <OpenMS/CHEMISTRY/Residue.h>
35
#include <OpenMS/CONCEPT/VersionInfo.h>
36
#include <OpenMS/FILTERING/SMOOTHING/SavitzkyGolayFilter.h>
37
#include <OpenMS/FILTERING/SMOOTHING/GaussFilter.h>
38
#include <OpenMS/FILTERING/BASELINE/MorphologicalFilter.h>
39
#include <OpenMS/FORMAT/IdXMLFile.h>
40
#include <OpenMS/FORMAT/FileHandler.h>
41
#include <OpenMS/FORMAT/DB/DBConnection.h>
42
#include <OpenMS/FORMAT/TextFile.h>
43
#include <OpenMS/FORMAT/DB/DBAdapter.h>
44
#include <OpenMS/FORMAT/FileTypes.h>
45
#include <OpenMS/FORMAT/FeatureXMLFile.h>
46
#include <OpenMS/FORMAT/ConsensusXMLFile.h>
47
#include <OpenMS/KERNEL/MSExperiment.h>
48
#include <OpenMS/METADATA/Precursor.h>
49
#include <OpenMS/SYSTEM/FileWatcher.h>
50
#include <OpenMS/SYSTEM/File.h>
51
#include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakPickerCWT.h>
52
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinder.h>
53
#include <OpenMS/VISUAL/DIALOGS/DataFilterDialog.h>
54
#include <OpenMS/VISUAL/DIALOGS/TOPPViewOpenDialog.h>
55
#include <OpenMS/VISUAL/DIALOGS/DBOpenDialog.h>
56
#include <OpenMS/VISUAL/DIALOGS/TheoreticalSpectrumGenerationDialog.h>
57
#include <OpenMS/VISUAL/DIALOGS/ToolsDialog.h>
58
#include <OpenMS/VISUAL/DIALOGS/TOPPViewPrefDialog.h>
59
#include <OpenMS/VISUAL/DIALOGS/SpectrumAlignmentDialog.h>
60
#include <OpenMS/VISUAL/ANNOTATION/Annotation1DPeakItem.h>
61
#include <OpenMS/VISUAL/ANNOTATION/Annotation1DTextItem.h>
62
#include <OpenMS/VISUAL/ANNOTATION/Annotation1DDistanceItem.h>
63
#include <OpenMS/VISUAL/SpectraViewWidget.h>
64
#include <OpenMS/VISUAL/Spectrum1DCanvas.h>
65
#include <OpenMS/VISUAL/Spectrum2DCanvas.h>
66
#include <OpenMS/VISUAL/Spectrum3DCanvas.h>
67
#include <OpenMS/VISUAL/Spectrum1DWidget.h>
68
#include <OpenMS/VISUAL/Spectrum2DWidget.h>
69
#include <OpenMS/VISUAL/Spectrum3DWidget.h>
70
#include <OpenMS/VISUAL/MetaDataBrowser.h>
71
#include <OpenMS/VISUAL/ParamEditor.h>
72
#include <OpenMS/VISUAL/ColorSelector.h>
73
#include <OpenMS/VISUAL/MultiGradientSelector.h>
74
#include <OpenMS/VISUAL/EnhancedTabBar.h>
75
#include <OpenMS/VISUAL/EnhancedWorkspace.h>
78
#include <OpenMS/VISUAL/APPLICATIONS/TOPPASBase.h>
79
#include <OpenMS/VISUAL/TOPPASScene.h>
80
#include <OpenMS/VISUAL/TOPPASMergerVertex.h>
81
#include <OpenMS/VISUAL/TOPPASInputFileListVertex.h>
82
#include <OpenMS/VISUAL/TOPPASOutputFileListVertex.h>
83
#include <OpenMS/VISUAL/TOPPASToolVertex.h>
87
#include <QtCore/QDate>
88
#include <QtCore/QDir>
89
#include <QtCore/QTime>
90
#include <QtCore/QUrl>
91
#include <QtGui/QCheckBox>
92
#include <QtGui/QCloseEvent>
93
#include <QtGui/QDesktopServices>
94
#include <QtGui/QDesktopWidget>
95
#include <QtGui/QDockWidget>
96
#include <QtGui/QFileDialog>
97
#include <QtGui/QHeaderView>
98
#include <QtGui/QInputDialog>
99
#include <QtGui/QListWidget>
100
#include <QtGui/QListWidgetItem>
101
#include <QtGui/QMenu>
102
#include <QtGui/QMenuBar>
103
#include <QtGui/QMessageBox>
104
#include <QtGui/QPainter>
105
#include <QtGui/QSplashScreen>
106
#include <QtGui/QStatusBar>
107
#include <QtGui/QTextEdit>
108
#include <QtGui/QToolBar>
109
#include <QtGui/QToolTip>
110
#include <QtGui/QToolButton>
111
#include <QtGui/QTreeWidget>
112
#include <QtGui/QTreeWidgetItem>
113
#include <QtGui/QWhatsThis>
115
#include <boost/math/special_functions/fpclassify.hpp>
124
using namespace Internal;
125
using namespace Math;
127
qreal TOPPViewBase::toppas_z_value_ = 42.0;
128
Int TOPPViewBase::toppas_node_offset_ = 0;
130
TOPPViewBase::TOPPViewBase(QWidget* parent):
132
DefaultParamHandler("TOPPViewBase"),
134
watcher_msgbox_(false),
135
toppas_clipboard_scene_(0)
137
setWindowTitle("TOPPView");
138
setWindowIcon(QIcon(":/TOPPView.png"));
140
//prevents errors caused by too small width,height values
141
setMinimumSize(400,400);
143
//enable drag-and-drop
144
setAcceptDrops(true);
146
// get geometry of first screen
147
QRect screen_geometry = QApplication::desktop()->screenGeometry();
148
// center main window
150
(int)(0.1 * screen_geometry.width()),
151
(int)(0.1 * screen_geometry.height()),
152
(int)(0.8 * screen_geometry.width()),
153
(int)(0.8 * screen_geometry.height())
156
//set & create temporary path -- make sure its a new subdirectory, as TOPPASScene will delete it when its done
157
toppas_tmp_path_ = (File::getTempDirectory() + String(QDir::separator()) + File::getUniqueName()).toQString();
159
qd.mkpath(toppas_tmp_path_);
161
// create dummy widget (to be able to have a layout), Tab bar and workspace
162
QWidget* dummy = new QWidget(this);
163
setCentralWidget(dummy);
164
QVBoxLayout* box_layout = new QVBoxLayout(dummy);
166
// create empty tab bar and workspace which will hold the main visualization widgets (e.g. spectra widgets...)
167
tab_bar_ = new EnhancedTabBar(dummy);
168
tab_bar_->setWhatsThis("Tab bar<BR><BR>Close tabs through the context menu or by double-clicking them.<BR>The tab bar accepts drag-and-drop from the layer bar.");
169
tab_bar_->addTab("dummy",4710);
170
tab_bar_->setMinimumSize(tab_bar_->sizeHint());
171
tab_bar_->removeId(4710);
173
connect(tab_bar_,SIGNAL(currentIdChanged(int)),this,SLOT(enhancedWorkspaceWindowChanged(int)));
174
connect(tab_bar_,SIGNAL(aboutToCloseId(int)),this,SLOT(closeByTab(int)));
176
//connect signals ans slots for drag-and-drop
177
connect(tab_bar_,SIGNAL(dropOnWidget(const QMimeData*,QWidget*)),this,SLOT(copyLayer(const QMimeData*,QWidget*)));
178
connect(tab_bar_,SIGNAL(dropOnTab(const QMimeData*,QWidget*,int)),this,SLOT(copyLayer(const QMimeData*,QWidget*,int)));
179
box_layout->addWidget(tab_bar_);
181
ws_= new EnhancedWorkspace(dummy);
182
connect(ws_,SIGNAL(windowActivated(QWidget*)),this,SLOT(updateToolBar()));
183
connect(ws_,SIGNAL(windowActivated(QWidget*)),this,SLOT(updateTabBar(QWidget*)));
184
connect(ws_,SIGNAL(windowActivated(QWidget*)),this,SLOT(updateLayerBar()));
185
connect(ws_,SIGNAL(windowActivated(QWidget*)),this,SLOT(updateViewBar()));
186
connect(ws_,SIGNAL(windowActivated(QWidget*)),this,SLOT(updateFilterBar()));
187
connect(ws_,SIGNAL(windowActivated(QWidget*)),this,SLOT(updateMenu()));
188
connect(ws_,SIGNAL(windowActivated(QWidget*)),this,SLOT(updateCurrentPath()));
189
connect(ws_,SIGNAL(dropReceived(const QMimeData*,QWidget*,int)),this,SLOT(copyLayer(const QMimeData*,QWidget*,int)));
191
box_layout->addWidget(ws_);
193
//################## MENUS #################
195
QMenu* file = new QMenu("&File",this);
196
menuBar()->addMenu(file);
197
file->addAction("&Open file",this,SLOT(openFileDialog()), Qt::CTRL+Qt::Key_O);
198
file->addAction("Open from &database",this,SLOT(openDatabaseDialog()), Qt::CTRL+Qt::Key_D);
199
file->addAction("Open &example file",this,SLOT(openExampleDialog()));
200
file->addAction("&Close",this,SLOT(closeFile()), Qt::CTRL+Qt::Key_W);
201
file->addSeparator();
203
// File menu: TOPPAS section
204
file->addAction("&New TOPPAS pipeline",this,SLOT(newPipeline()), Qt::CTRL+Qt::Key_N);
205
file->addAction("&Include TOPPAS pipeline",this,SLOT(includePipeline()), Qt::CTRL+Qt::Key_I);
206
file->addAction("&Save TOPPAS pipeline",this,SLOT(savePipeline()), Qt::CTRL+Qt::Key_S);
207
file->addAction("Save TOPPAS pipeline &As",this,SLOT(saveCurrentPipelineAs()), Qt::CTRL+Qt::SHIFT+Qt::Key_S);
208
file->addAction("&Load TOPPAS resource file",this,SLOT(loadPipelineResourceFile()));
209
file->addAction("Save TOPPAS &resource file",this,SLOT(savePipelineResourceFile()));
210
file->addAction("Refresh TOPPAS ¶meters",this,SLOT(refreshPipelineParameters()), Qt::CTRL+Qt::SHIFT+Qt::Key_P);
211
file->addSeparator();
214
file->addAction("&Show meta data (file)",this,SLOT(metadataFileDialog()));
215
file->addAction("&Show meta data (database)",this,SLOT(metadataDatabaseDialog()));
216
file->addSeparator();
219
QMenu* recent_menu = new QMenu("&Recent files", this);
220
recent_actions_.resize(20);
221
for (Size i = 0; i<20; ++i)
223
recent_actions_[i] = recent_menu->addAction("",this,SLOT(openRecentFile()));
224
recent_actions_[i]->setVisible(false);
226
file->addMenu(recent_menu);
228
file->addSeparator();
229
file->addAction("&Preferences",this, SLOT(preferencesDialog()));
230
file->addAction("&Quit",qApp,SLOT(quit()));
233
QMenu* tools = new QMenu("&Tools",this);
234
menuBar()->addMenu(tools);
235
tools->addAction("&Go to",this,SLOT(showGoToDialog()), Qt::CTRL+Qt::Key_G);
236
tools->addAction("&Edit meta data",this,SLOT(editMetadata()), Qt::CTRL+Qt::Key_M);
237
tools->addAction("&Statistics",this,SLOT(layerStatistics()));
238
tools->addSeparator();
240
tools->addAction("Apply TOPP tool (whole layer)", this, SLOT(showTOPPDialog()), Qt::CTRL+Qt::Key_T)->setData(false);
241
tools->addAction("Apply TOPP tool (visible layer data)", this, SLOT(showTOPPDialog()), Qt::CTRL+Qt::SHIFT+Qt::Key_T)->setData(true);
242
tools->addAction("Rerun TOPP tool", this, SLOT(rerunTOPPTool()),Qt::Key_F4);
243
tools->addSeparator();
244
tools->addAction("&Annotate with identification", this, SLOT(annotateWithID()), Qt::CTRL+Qt::Key_I);
245
tools->addAction("Align spectra", this, SLOT(showSpectrumAlignmentDialog()));
246
tools->addAction("Generate theoretical spectrum", this, SLOT(showSpectrumGenerationDialog()));
249
// pipeline menu (TOPPAS pipeline)
250
QMenu* toppas_pipeline = new QMenu("TOPPAS &Pipeline", this);
251
toppas_pipeline->addAction("&Run (F5)",this,SLOT(runPipeline()));
252
toppas_pipeline->addAction("&Abort",this,SLOT(abortPipeline()));
253
menuBar()->addMenu(toppas_pipeline);
256
QMenu* layer = new QMenu("&Layer",this);
257
menuBar()->addMenu(layer);
258
layer->addAction("Save all data", this, SLOT(saveLayerAll()), Qt::CTRL+Qt::Key_S);
259
layer->addAction("Save visible data", this, SLOT(saveLayerVisible()), Qt::CTRL+Qt::SHIFT+Qt::Key_S);
260
layer->addSeparator();
261
layer->addAction("Show/hide grid lines", this, SLOT(toggleGridLines()), Qt::CTRL+Qt::Key_R);
262
layer->addAction("Show/hide axis legends", this, SLOT(toggleAxisLegends()), Qt::CTRL+Qt::Key_L);
263
layer->addSeparator();
264
layer->addAction("Preferences", this, SLOT(showPreferences()));
267
QMenu* windows = new QMenu("&Windows", this);
268
menuBar()->addMenu(windows);
269
windows->addAction("&Cascade",this->ws_,SLOT(cascade()));
270
windows->addAction("&Tile automatic",this->ws_,SLOT(tile()));
271
windows->addAction(QIcon(":/tile_horizontal.png"),"Tile &vertical",this,SLOT(tileHorizontal()));
272
windows->addAction(QIcon(":/tile_vertical.png"),"Tile &horizontal",this,SLOT(tileVertical()));
273
windows->addSeparator();
276
QMenu* help = new QMenu("&Help", this);
277
menuBar()->addMenu(help);
278
help->addAction(QWhatsThis::createAction(help));
279
help->addSeparator();
280
QAction* action = help->addAction("OpenMS website",this,SLOT(showURL()));
281
action->setData("http://www.OpenMS.de");
282
action = help->addAction("Tutorials and documentation",this,SLOT(showURL()), Qt::Key_F1);
283
action->setData(String(File::getOpenMSDataPath() + "/../../doc/html/index.html").toQString());
285
help->addSeparator();
286
help->addAction("&About",this,SLOT(showAboutDialog()));
289
message_label_ = new QLabel(statusBar());
290
statusBar()->addWidget(message_label_,1);
292
rt_label_ = new QLabel("RT: 12345678", statusBar());
293
rt_label_->setMinimumSize(rt_label_->sizeHint());
294
rt_label_->setText("");
295
statusBar()->addPermanentWidget(rt_label_,0);
296
mz_label_ = new QLabel("m/z: 123456780912", statusBar());
297
mz_label_->setMinimumSize(mz_label_->sizeHint());
298
mz_label_->setText("");
299
statusBar()->addPermanentWidget(mz_label_,0);
301
//################## TOOLBARS #################
302
//create toolbars and connect signals
305
//--Basic tool bar for all views--
306
tool_bar_ = addToolBar("Basic tool bar");
309
intensity_button_group_ = new QButtonGroup(tool_bar_);
310
intensity_button_group_->setExclusive(true);
312
b = new QToolButton(tool_bar_);
313
b->setIcon(QIcon(":/lin.png"));
314
b->setToolTip("Intensity: Normal");
315
b->setShortcut(Qt::Key_N);
316
b->setCheckable(true);
317
b->setWhatsThis("Intensity: Normal<BR><BR>Intensity is displayed unmodified.<BR>(Hotkey: N)");
318
intensity_button_group_->addButton(b,SpectrumCanvas::IM_NONE);
319
tool_bar_->addWidget(b);
321
b = new QToolButton(tool_bar_);
322
b->setIcon(QIcon(":/percentage.png"));
323
b->setToolTip("Intensity: Percentage");
324
b->setShortcut(Qt::Key_P);
325
b->setCheckable(true);
326
b->setWhatsThis("Intensity: Percentage<BR><BR>Intensity is displayed as a percentage of the layer"
327
" maximum intensity. If only one layer is displayed this mode behaves like the"
328
" normal mode. If more than one layer is displayed intensities are aligned."
330
intensity_button_group_->addButton(b,SpectrumCanvas::IM_PERCENTAGE);
331
tool_bar_->addWidget(b);
333
b = new QToolButton(tool_bar_);
334
b->setIcon(QIcon(":/snap.png"));
335
b->setToolTip("Intensity: Snap to maximum displayed intensity");
336
b->setShortcut(Qt::Key_S);
337
b->setCheckable(true);
338
b->setWhatsThis("Intensity: Snap to maximum displayed intensity<BR><BR> In this mode the"
339
" color gradient is adapted to the maximum currently displayed intensity."
341
intensity_button_group_->addButton(b,SpectrumCanvas::IM_SNAP);
342
tool_bar_->addWidget(b);
344
b = new QToolButton(tool_bar_);
345
b->setIcon(QIcon(":/log.png"));
346
b->setToolTip("Intensity: Use log scaling for colors");
347
b->setCheckable(true);
348
b->setWhatsThis("Intensity: Logarithmic scaling of intensities for color calculation");
349
intensity_button_group_->addButton(b,SpectrumCanvas::IM_LOG);
350
tool_bar_->addWidget(b);
352
connect(intensity_button_group_,SIGNAL(buttonClicked(int)),this,SLOT(setIntensityMode(int)));
353
tool_bar_->addSeparator();
356
QAction* reset_zoom_button = tool_bar_->addAction(QIcon(":/reset_zoom.png"), "Reset Zoom", this, SLOT(resetZoom()));
357
reset_zoom_button->setWhatsThis("Reset zoom: Zooms out as far as possible and resets the zoom history.<BR>(Hotkey: Backspace)");
362
tool_bar_1d_ = addToolBar("1D tool bar");
365
draw_group_1d_ = new QButtonGroup(tool_bar_1d_);
366
draw_group_1d_->setExclusive(true);
368
b = new QToolButton(tool_bar_1d_);
369
b->setIcon(QIcon(":/peaks.png"));
370
b->setToolTip("Peak mode");
371
b->setShortcut(Qt::Key_I);
372
b->setCheckable(true);
373
b->setWhatsThis("1D Draw mode: Peaks<BR><BR>Peaks are diplayed as sticks.");
374
draw_group_1d_->addButton(b,Spectrum1DCanvas::DM_PEAKS);
375
tool_bar_1d_->addWidget(b);
377
b = new QToolButton(tool_bar_1d_);
378
b->setIcon(QIcon(":/lines.png"));
379
b->setToolTip("Raw data mode");
380
b->setShortcut(Qt::Key_R);
381
b->setCheckable(true);
382
b->setWhatsThis("1D Draw mode: Raw data<BR><BR>Peaks are diplayed as a continous line.");
383
draw_group_1d_->addButton(b,Spectrum1DCanvas::DM_CONNECTEDLINES);
384
tool_bar_1d_->addWidget(b);
386
connect(draw_group_1d_,SIGNAL(buttonClicked(int)),this,SLOT(setDrawMode1D(int)));
387
tool_bar_->addSeparator();
389
//--2D peak toolbar--
390
tool_bar_2d_peak_ = addToolBar("2D peak tool bar");
392
dm_precursors_2d_ = tool_bar_2d_peak_->addAction(QIcon(":/precursors.png"),"Show fragment scan precursors");
393
dm_precursors_2d_->setCheckable(true);
394
dm_precursors_2d_->setWhatsThis("2D peak draw mode: Precursors<BR><BR>fragment scan precursor peaks are marked.<BR>(Hotkey: 1)");
395
dm_precursors_2d_->setShortcut(Qt::Key_1);
397
connect(dm_precursors_2d_, SIGNAL(toggled(bool)), this, SLOT(changeLayerFlag(bool)));
399
projections_2d_ = tool_bar_2d_peak_->addAction(QIcon(":/projections.png"), "Show Projections" ,this, SLOT(toggleProjections()));
400
projections_2d_->setWhatsThis("Projections: Shows projections of peak data along RT and MZ axis.<BR>(Hotkey: 2)");
401
projections_2d_->setShortcut(Qt::Key_2);
403
//--2D feature toolbar--
404
tool_bar_2d_feat_ = addToolBar("2D feature tool bar");
406
dm_hull_2d_ = tool_bar_2d_feat_->addAction(QIcon(":/convexhull.png"),"Show feature convex hull");
407
dm_hull_2d_->setCheckable(true);
408
dm_hull_2d_->setWhatsThis("2D feature draw mode: Convex hull<BR><BR>The convex hull of the feature is displayed.<BR>(Hotkey: 5)");
409
dm_hull_2d_->setShortcut(Qt::Key_5);
410
connect(dm_hull_2d_, SIGNAL(toggled(bool)), this, SLOT(changeLayerFlag(bool)));
412
dm_hulls_2d_ = tool_bar_2d_feat_->addAction(QIcon(":/convexhulls.png"),"Show feature convex hulls");
413
dm_hulls_2d_->setCheckable(true);
414
dm_hulls_2d_->setWhatsThis("2D feature draw mode: Convex hulls<BR><BR>The convex hulls of the feature are displayed: One for each mass trace.<BR>(Hotkey: 6)");
415
dm_hulls_2d_->setShortcut(Qt::Key_6);
416
connect(dm_hulls_2d_, SIGNAL(toggled(bool)), this, SLOT(changeLayerFlag(bool)));
419
dm_label_2d_ = new QToolButton(tool_bar_2d_feat_);
420
dm_label_2d_->setPopupMode(QToolButton::MenuButtonPopup);
421
QAction* action2 = new QAction(QIcon(":/labels.png"), "Show feature label", dm_label_2d_);
422
action2->setCheckable(true);
423
action2->setWhatsThis("2D feature draw mode: Labels<BR><BR>Display different kinds of annotation next to features.<BR>(Hotkey: 7)");
424
action2->setShortcut(Qt::Key_7);
425
dm_label_2d_->setDefaultAction(action2);
426
tool_bar_2d_feat_->addWidget(dm_label_2d_);
427
connect(dm_label_2d_, SIGNAL(triggered(QAction*)), this, SLOT(changeLabel(QAction*)));
429
group_label_2d_ = new QActionGroup(dm_label_2d_);
430
QMenu* menu = new QMenu(dm_label_2d_);
431
for (Size i = 0; i < LayerData::SIZE_OF_LABEL_TYPE; ++i)
433
QAction* temp = group_label_2d_->addAction(
434
QString(LayerData::NamesOfLabelType[i].c_str()));
435
temp->setCheckable(true);
436
if (i == 0) temp->setChecked(true);
437
menu->addAction(temp);
439
dm_label_2d_->setMenu(menu);
441
// unassigned peptide identifications:
442
dm_unassigned_2d_ = new QToolButton(tool_bar_2d_feat_);
443
dm_unassigned_2d_->setPopupMode(QToolButton::MenuButtonPopup);
444
QAction* action_unassigned = new QAction(QIcon(":/unassigned.png"), "Show unassigned peptide identifications", dm_unassigned_2d_);
445
action_unassigned->setCheckable(true);
446
action_unassigned->setWhatsThis("2D feature draw mode: Unassigned peptide identifications<BR><BR>Show unassigned peptide identifications by precursor m/z or by peptide mass.<BR>(Hotkey: 8)");
447
action_unassigned->setShortcut(Qt::Key_8);
448
dm_unassigned_2d_->setDefaultAction(action_unassigned);
449
tool_bar_2d_feat_->addWidget(dm_unassigned_2d_);
450
connect(dm_unassigned_2d_, SIGNAL(triggered(QAction*)), this, SLOT(changeUnassigned(QAction*)));
452
group_unassigned_2d_ = new QActionGroup(dm_unassigned_2d_);
453
menu = new QMenu(dm_unassigned_2d_);
454
StringList options = StringList::create(
455
"Don't show,Show by precursor m/z,Show by peptide mass");
456
for (StringList::iterator opt_it = options.begin(); opt_it != options.end();
459
QAction* temp = group_unassigned_2d_->addAction(opt_it->toQString());
460
temp->setCheckable(true);
461
if (opt_it == options.begin()) temp->setChecked(true);
462
menu->addAction(temp);
464
dm_unassigned_2d_->setMenu(menu);
466
//--2D consensus toolbar--
467
tool_bar_2d_cons_ = addToolBar("2D peak tool bar");
469
dm_elements_2d_ = tool_bar_2d_cons_->addAction(QIcon(":/elements.png"),"Show consensus feature element positions");
470
dm_elements_2d_->setCheckable(true);
471
dm_elements_2d_->setWhatsThis("2D consensus feature draw mode: Elements<BR><BR>The individual elements that make up the consensus feature are drawn.<BR>(Hotkey: 9)");
472
dm_elements_2d_->setShortcut(Qt::Key_9);
473
connect(dm_elements_2d_, SIGNAL(toggled(bool)), this, SLOT(changeLayerFlag(bool)));
475
//--2D identifications toolbar--
476
tool_bar_2d_ident_ = addToolBar("2D identifications tool bar");
478
dm_ident_2d_ = tool_bar_2d_ident_->addAction(QIcon(":/peptidemz.png"), "Use theoretical peptide mass for m/z positions (default: precursor mass)");
479
dm_ident_2d_->setCheckable(true);
480
dm_ident_2d_->setWhatsThis("2D peptide identification draw mode: m/z source<BR><BR>Toggle between precursor mass (default) and theoretical peptide mass as source for the m/z positions of peptide identifications.<BR>(Hotkey: 5)");
481
dm_ident_2d_->setShortcut(Qt::Key_5);
482
connect(dm_ident_2d_, SIGNAL(toggled(bool)), this, SLOT(changeLayerFlag(bool)));
484
//################## Dock widgets #################
486
layer_dock_widget_ = new QDockWidget("Layers", this);
487
addDockWidget(Qt::RightDockWidgetArea, layer_dock_widget_);
488
layer_manager_ = new QListWidget(layer_dock_widget_);
489
layer_manager_->setWhatsThis("Layer bar<BR><BR>Here the available layers are shown. Left-click on a layer to select it.<BR>Layers can be shown and hidden using the checkboxes in front of the name.<BR> Renaming and removing a layer is possible through the context menu.<BR>Dragging a layer to the tab bar copies the layer.<BR>Double-clicking a layer open its preferences.<BR>You can use the 'PageUp' and 'PageDown' buttons to change the selected layer.");
491
layer_dock_widget_->setWidget(layer_manager_);
492
layer_manager_->setContextMenuPolicy(Qt::CustomContextMenu);
493
layer_manager_->setDragEnabled(true);
494
connect(layer_manager_,SIGNAL(currentRowChanged(int)),this,SLOT(layerSelectionChange(int)));
495
connect(layer_manager_,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(layerContextMenu(const QPoint&)));
496
connect(layer_manager_,SIGNAL(itemChanged(QListWidgetItem*)),this,SLOT(layerVisibilityChange(QListWidgetItem*)));
497
connect(layer_manager_,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(layerEdit(QListWidgetItem*)));
499
windows->addAction(layer_dock_widget_->toggleViewAction());
502
views_dockwidget_ = new QDockWidget("Views", this);
503
addDockWidget(Qt::RightDockWidgetArea, views_dockwidget_);
504
views_tabwidget_ = new QTabWidget(views_dockwidget_);
505
views_dockwidget_->setWidget(views_tabwidget_);
507
spectra_view_widget_ = new SpectraViewWidget();
508
connect(spectra_view_widget_, SIGNAL(showSpectrumMetaData(int)), this, SLOT(showSpectrumMetaData(int)));
509
connect(spectra_view_widget_, SIGNAL(showSpectrumAs1D(int)), this, SLOT(showSpectrumAs1D(int)));
510
connect(spectra_view_widget_, SIGNAL(spectrumSelected(int)), this, SLOT(activate1DSpectrum(int)));
511
connect(spectra_view_widget_, SIGNAL(spectrumDoubleClicked(int)), this, SLOT(showSpectrumAs1D(int)));
512
spectraview_behavior_ = new TOPPViewSpectraViewBehavior(this);
513
view_behavior_ = spectraview_behavior_;
515
spectra_identification_view_widget_ = new SpectraIdentificationViewWidget(Param());
516
connect(spectra_identification_view_widget_, SIGNAL(spectrumDeselected(int)), this, SLOT(deactivate1DSpectrum(int)));
517
connect(spectra_identification_view_widget_, SIGNAL(showSpectrumAs1D(int)), this, SLOT(showSpectrumAs1D(int)));
518
connect(spectra_identification_view_widget_, SIGNAL(spectrumSelected(int)), this, SLOT(activate1DSpectrum(int)));
519
identificationview_behavior_ = new TOPPViewIdentificationViewBehavior(this);
520
connect(spectra_identification_view_widget_, SIGNAL(requestVisibleArea1D(DoubleReal, DoubleReal)), identificationview_behavior_, SLOT(setVisibleArea1D(DoubleReal, DoubleReal)));
522
// topp tool dock widget
523
TOPPASTreeView* tools_tree_view = TOPPASBase::createTOPPToolsTreeWidget();
524
connect (tools_tree_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(insertNewVertexInCenter_(QTreeWidgetItem*)));
526
views_tabwidget_->addTab(spectra_view_widget_, "Scan view");
527
views_tabwidget_->addTab(spectra_identification_view_widget_, "Identification view");
528
views_tabwidget_->setTabEnabled(1, false);
529
views_tabwidget_->addTab(tools_tree_view, "TOPPAS view");
530
views_tabwidget_->setTabEnabled(2, false);
532
// switch between different view tabs
533
connect(views_tabwidget_, SIGNAL(currentChanged(int)), this, SLOT(viewChanged(int)));
535
// add hide/show option to dock widget
536
windows->addAction(views_dockwidget_->toggleViewAction());
538
// filter dock widget
539
filter_dock_widget_ = new QDockWidget("Data filters", this);
540
addDockWidget(Qt::RightDockWidgetArea, filter_dock_widget_);
541
QWidget* tmp_widget = new QWidget(); //dummy widget as QDockWidget takes only one widget
542
filter_dock_widget_->setWidget(tmp_widget);
544
QVBoxLayout* vbl = new QVBoxLayout(tmp_widget);
546
filters_ = new QListWidget(tmp_widget);
547
filters_->setSelectionMode(QAbstractItemView::NoSelection);
548
filters_->setWhatsThis("Data filter bar<BR><BR>Here filtering options for the current layer can be set.<BR>Through the context menu you can add, remove and edit filters.<BR>For convenience, editing filters is also possible by double-clicking them.");
549
filters_->setContextMenuPolicy(Qt::CustomContextMenu);
550
connect(filters_,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(filterContextMenu(const QPoint&)));
551
connect(filters_,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(filterEdit(QListWidgetItem*)));
552
vbl->addWidget(filters_);
554
filters_check_box_ = new QCheckBox("Enable/disable all filters", tmp_widget);
555
connect(filters_check_box_,SIGNAL(toggled(bool)),this,SLOT(layerFilterVisibilityChange(bool)));
556
vbl->addWidget(filters_check_box_);
558
windows->addAction(filter_dock_widget_->toggleViewAction());
561
QDockWidget* log_bar = new QDockWidget("Log", this);
562
addDockWidget(Qt::BottomDockWidgetArea, log_bar);
563
log_ = new QTextEdit(log_bar);
564
log_->setReadOnly(true);
565
log_->setContextMenuPolicy(Qt::CustomContextMenu);
566
connect(log_,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(logContextMenu(const QPoint&)));
567
log_bar->setWidget(log_);
569
windows->addAction(log_bar->toggleViewAction());
571
//################## DEFAULTS #################
572
initializeDefaultParameters_();
574
// store defaults in param_
581
current_path_ = param_.getValue("preferences:default_path");
588
//######################### File System Watcher ###########################################
589
watcher_ = new FileWatcher(this);
590
connect(watcher_,SIGNAL(fileChanged(const String&)),this, SLOT(fileChanged_(const String&)));
593
void TOPPViewBase::initializeDefaultParameters_()
596
defaults_.setValue("preferences:default_map_view", "2d", "Default visualization mode for maps.");
597
defaults_.setValidStrings("preferences:default_map_view",StringList::create("2d,3d"));
598
defaults_.setValue("preferences:default_path", ".", "Default path for loading and storing files.");
599
defaults_.setValue("preferences:default_path_current", "true", "If the current path is preferred over the default path.");
600
defaults_.setValidStrings("preferences:default_path_current",StringList::create("true,false"));
601
defaults_.setValue("preferences:tmp_file_path", QDir::tempPath(), "Path where temporary files can be created.");
602
defaults_.setValue("preferences:number_of_recent_files", 15, "Number of recent files in the main menu.");
603
defaults_.setMinInt("preferences:number_of_recent_files",5);
604
defaults_.setMaxInt("preferences:number_of_recent_files",20);
605
defaults_.setValue("preferences:legend", "show", "Legend visibility");
606
defaults_.setValidStrings("preferences:legend",StringList::create("show,hide"));
607
defaults_.setValue("preferences:intensity_cutoff", "off","Low intensity cutoff for maps.");
608
defaults_.setValidStrings("preferences:intensity_cutoff",StringList::create("on,off"));
609
defaults_.setValue("preferences:on_file_change","ask","What action to take, when a data file changes. Do nothing, update automatically or ask the user.");
610
defaults_.setValidStrings("preferences:on_file_change",StringList::create("none,ask,update automatically"));
611
defaults_.setValue("preferences:topp_cleanup", "true", "If the temporary files for calling of TOPP tools should be removed after the call.");
612
defaults_.setValidStrings("preferences:topp_cleanup",StringList::create("true,false"));
614
defaults_.setValue("preferences:db:host", "localhost", "Database server host name.");
615
defaults_.setValue("preferences:db:login", "NoName", "Database login.");
616
defaults_.setValue("preferences:db:name", "OpenMS", "Database name.");
617
defaults_.setValue("preferences:db:port", 3306, "Database server port.");
618
defaults_.setSectionDescription("preferences:db","Database settings.");
620
Spectrum1DCanvas* def1 = new Spectrum1DCanvas(Param(),0);
621
defaults_.insert("preferences:1d:",def1->getDefaults());
623
defaults_.setSectionDescription("preferences:1d","Settings for single spectrum view.");
625
Spectrum2DCanvas* def2 = new Spectrum2DCanvas(Param(),0);
626
defaults_.insert("preferences:2d:",def2->getDefaults());
627
defaults_.setSectionDescription("preferences:2d","Settings for 2D map view.");
630
Spectrum3DCanvas* def3 = new Spectrum3DCanvas(Param(),0);
631
defaults_.insert("preferences:3d:",def3->getDefaults());
633
defaults_.setSectionDescription("preferences:3d","Settings for 3D map view.");
634
// identification view
635
SpectraIdentificationViewWidget* def4 = new SpectraIdentificationViewWidget(Param(),0);
636
defaults_.insert("preferences:idview:",def4->getDefaults());
638
defaults_.setSectionDescription("preferences:idview","Settings for identification view.");
639
defaults_.setValue("preferences:version","none","OpenMS version, used to check if the TOPPView.ini is up-to-date");
640
subsections_.push_back("preferences:RecentFiles");
643
void TOPPViewBase::closeEvent(QCloseEvent* event)
645
ws_->closeAllWindows();
649
void TOPPViewBase::showURL()
651
QAction* action = qobject_cast<QAction*>(sender());
652
if (!QDesktopServices::openUrl(QUrl(action->data().toString())))
654
QMessageBox::warning(this, tr("Error"),
655
tr("Unable to open\n") +
656
action->data().toString() +
657
tr("\n\nPossible reason: security settings or misconfigured Operating System"));
661
void TOPPViewBase::addDataDB(UInt db_id, bool show_options, String caption, UInt window_id)
664
setCursor(Qt::WaitCursor);
669
if (!con.isConnected())
671
setCursor(Qt::ArrowCursor);
678
// create managed pointer to experiment data
679
ExperimentType* exp = new ExperimentType();
680
ExperimentSharedPtrType exp_sptr(exp);
682
FeatureMapType* dummy_map = new FeatureMapType();
683
FeatureMapSharedPtrType dummy_map_sptr(dummy_map);
685
ConsensusMapType* dummy_map2 = new ConsensusMapType();
686
ConsensusMapSharedPtrType dummy_map2_sptr(dummy_map2);
688
vector<PeptideIdentification> dummy_peptides;
691
db.loadExperiment(db_id, *exp);
693
catch (Exception::BaseException& e)
695
QMessageBox::critical(this,"Error",(String("Error while reading data: ")+e.what()).c_str());
696
setCursor(Qt::ArrowCursor);
699
exp_sptr->sortSpectra(true);
700
exp_sptr->updateRanges(1);
702
//determine if the data is 1D or 2D
703
QSqlQuery result = con.executeQuery(String("SELECT count(id) from DATA_Spectrum where fid_MSExperiment='")+db_id+"' and MSLevel='1'");
704
LayerData::DataType data_type = ((result.value(0).toInt()>1) ?
706
LayerData::DT_CHROMATOGRAM);
709
if (caption=="") caption = String("DB entry ")+db_id;
710
addData(dummy_map_sptr, dummy_map2_sptr, dummy_peptides, exp_sptr, data_type, false, show_options, true, "", caption, window_id);
713
setCursor(Qt::ArrowCursor);
717
bool TOPPViewBase::containsMS1Scans(const ExperimentType& exp)
719
//test if no scans with MS-level 1 exist => prevent deadlock
720
bool ms1_present = false;
721
for (Size i = 0; i < exp.size(); ++i)
723
if (exp[i].getMSLevel() == 1)
733
float TOPPViewBase::estimateNoiseFromRandomMS1Scans(const ExperimentType& exp, UInt n_scans)
735
if (!TOPPViewBase::containsMS1Scans(exp))
743
while (count < n_scans)
745
UInt scan = (UInt)( (double)rand() / ((double)(RAND_MAX)+1.0f) * (double)(exp.size()-1) );
747
if (scan < exp.size() && exp[scan].getMSLevel()==1 && exp[scan].size()!=0)
750
tmp.reserve(exp[scan].size());
751
for(SpectrumType::ConstIterator it = exp[scan].begin()
752
; it != exp[scan].end()
755
tmp.push_back(it->getIntensity());
757
std::sort(tmp.begin(),tmp.end());
758
noise += tmp[(UInt)ceil((float)(tmp.size()-1)/1.25f)];
762
return noise / (DoubleReal)n_scans;
766
UInt TOPPViewBase::countMS1Zeros(const ExperimentType& exp)
768
if (!TOPPViewBase::containsMS1Scans(exp))
774
for (Size i = 0; i != exp.size(); ++i)
776
if (exp[i].getMSLevel() != 1) // skip non MS1-level scans
780
for(Size j = 0; j != exp[i].size(); ++j)
782
DoubleReal intensity = exp[i][j].getIntensity();
783
if (intensity == 0.0)
793
bool TOPPViewBase::hasPeptideIdentifications(const ExperimentType& map)
795
for(Size i = 0; i!= map.size(); ++i)
797
if ( !map[i].getPeptideIdentifications().empty())
805
void TOPPViewBase::preferencesDialog()
807
Internal::TOPPViewPrefDialog dlg(this);
809
// --------------------------------------------------------------------
810
// Get pointers to the widget in the preferences dialog
813
QLineEdit* default_path = dlg.findChild<QLineEdit*>("default_path");
814
QCheckBox* default_path_current = dlg.findChild<QCheckBox*>("default_path_current");
815
QLineEdit* temp_path = dlg.findChild<QLineEdit*>("temp_path");
816
QSpinBox* recent_files = dlg.findChild<QSpinBox*>("recent_files");
817
QComboBox* map_default = dlg.findChild<QComboBox*>("map_default");
818
QComboBox* map_cutoff = dlg.findChild<QComboBox*>("map_cutoff");
819
QComboBox* on_file_change = dlg.findChild<QComboBox*>("on_file_change");
822
QLineEdit* db_host = dlg.findChild<QLineEdit*>("db_host");
823
QSpinBox* db_port = dlg.findChild<QSpinBox*>("db_port");
824
QLineEdit* db_name = dlg.findChild<QLineEdit*>("db_name");
825
QLineEdit* db_login = dlg.findChild<QLineEdit*>("db_login");
828
ColorSelector* color_1D = dlg.findChild<ColorSelector*>("color_1D");
829
ColorSelector* selected_1D = dlg.findChild<ColorSelector*>("selected_1D");
830
ColorSelector* icon_1D = dlg.findChild<ColorSelector*>("icon_1D");
833
MultiGradientSelector* peak_2D = dlg.findChild<MultiGradientSelector*>("peak_2D");
834
QComboBox* mapping_2D = dlg.findChild<QComboBox*>("mapping_2D");
835
QComboBox* feature_icon_2D = dlg.findChild<QComboBox*>("feature_icon_2D");
836
QSpinBox* feature_icon_size_2D = dlg.findChild<QSpinBox*>("feature_icon_size_2D");
839
MultiGradientSelector* peak_3D = dlg.findChild<MultiGradientSelector*>("peak_3D");
840
QComboBox* shade_3D = dlg.findChild<QComboBox*>("shade_3D");
841
QSpinBox* line_width_3D = dlg.findChild<QSpinBox*>("line_width_3D");
843
// identification view tab
844
QListWidget* id_view_ions = dlg.findChild<QListWidget*>("ions_list_widget");
845
QDoubleSpinBox* a_intensity = dlg.findChild<QDoubleSpinBox*>("a_intensity");
846
QDoubleSpinBox* b_intensity = dlg.findChild<QDoubleSpinBox*>("b_intensity");
847
QDoubleSpinBox* c_intensity = dlg.findChild<QDoubleSpinBox*>("c_intensity");
848
QDoubleSpinBox* x_intensity = dlg.findChild<QDoubleSpinBox*>("x_intensity");
849
QDoubleSpinBox* y_intensity = dlg.findChild<QDoubleSpinBox*>("y_intensity");
850
QDoubleSpinBox* z_intensity = dlg.findChild<QDoubleSpinBox*>("z_intensity");
852
QDoubleSpinBox* tolerance = dlg.findChild<QDoubleSpinBox*>("tolerance");
853
QCheckBox* is_relative_tolerance = dlg.findChild<QCheckBox*>("unit_is_ppm");
855
QDoubleSpinBox* relative_loss_intensity = dlg.findChild<QDoubleSpinBox*>("relative_loss_intensity");
856
QSpinBox* max_isotopes = dlg.findChild<QSpinBox*>("max_isotopes");
857
QSpinBox* charge = dlg.findChild<QSpinBox*>("charge");
859
QList<QListWidgetItem*> a_ions = id_view_ions->findItems("A-ions", Qt::MatchFixedString);
860
QList<QListWidgetItem*> b_ions = id_view_ions->findItems("B-ions", Qt::MatchFixedString);
861
QList<QListWidgetItem*> c_ions = id_view_ions->findItems("C-ions", Qt::MatchFixedString);
862
QList<QListWidgetItem*> x_ions = id_view_ions->findItems("X-ions", Qt::MatchFixedString);
863
QList<QListWidgetItem*> y_ions = id_view_ions->findItems("Y-ions", Qt::MatchFixedString);
864
QList<QListWidgetItem*> z_ions = id_view_ions->findItems("Z-ions", Qt::MatchFixedString);
865
QList<QListWidgetItem*> pc_ions = id_view_ions->findItems("Precursor", Qt::MatchFixedString);
866
QList<QListWidgetItem*> nl_ions = id_view_ions->findItems("Neutral losses", Qt::MatchFixedString);
867
QList<QListWidgetItem*> ic_ions = id_view_ions->findItems("Isotope clusters", Qt::MatchFixedString);
868
QList<QListWidgetItem*> ai_ions = id_view_ions->findItems("Abundant immonium-ions", Qt::MatchFixedString);
870
// --------------------------------------------------------------------
871
// Set dialog entries from current parameter object (default values)
874
default_path->setText(param_.getValue("preferences:default_path").toQString());
875
if ((String)param_.getValue("preferences:default_path_current")=="true")
877
default_path_current->setChecked(true);
881
default_path_current->setChecked(false);
883
temp_path->setText(param_.getValue("preferences:tmp_file_path").toQString());
884
recent_files->setValue((Int)param_.getValue("preferences:number_of_recent_files"));
885
map_default->setCurrentIndex(map_default->findText(param_.getValue("preferences:default_map_view").toQString()));
886
map_cutoff->setCurrentIndex(map_cutoff->findText(param_.getValue("preferences:intensity_cutoff").toQString()));
887
on_file_change->setCurrentIndex(on_file_change->findText(param_.getValue("preferences:on_file_change").toQString()));
890
db_host->setText(param_.getValue("preferences:db:host").toQString());
891
db_port->setValue((Int)param_.getValue("preferences:db:port"));
892
db_name->setText(param_.getValue("preferences:db:name").toQString());
893
db_login->setText(param_.getValue("preferences:db:login").toQString());
896
color_1D->setColor(QColor(param_.getValue("preferences:1d:peak_color").toQString()));
897
selected_1D->setColor(QColor(param_.getValue("preferences:1d:highlighted_peak_color").toQString()));
898
icon_1D->setColor(QColor(param_.getValue("preferences:1d:icon_color").toQString()));
901
peak_2D->gradient().fromString(param_.getValue("preferences:2d:dot:gradient"));
902
mapping_2D->setCurrentIndex(mapping_2D->findText(param_.getValue("preferences:2d:mapping_of_mz_to").toQString()));
903
feature_icon_2D->setCurrentIndex(feature_icon_2D->findText(param_.getValue("preferences:2d:dot:feature_icon").toQString()));
904
feature_icon_size_2D->setValue((Int)param_.getValue("preferences:2d:dot:feature_icon_size"));
907
peak_3D->gradient().fromString(param_.getValue("preferences:3d:dot:gradient"));
908
shade_3D->setCurrentIndex((Int)param_.getValue("preferences:3d:dot:shade_mode"));
909
line_width_3D->setValue((Int)param_.getValue("preferences:3d:dot:line_width"));
912
a_intensity->setValue((DoubleReal)param_.getValue("preferences:idview:a_intensity"));
913
b_intensity->setValue((DoubleReal)param_.getValue("preferences:idview:b_intensity"));
914
c_intensity->setValue((DoubleReal)param_.getValue("preferences:idview:c_intensity"));
915
x_intensity->setValue((DoubleReal)param_.getValue("preferences:idview:x_intensity"));
916
y_intensity->setValue((DoubleReal)param_.getValue("preferences:idview:y_intensity"));
917
z_intensity->setValue((DoubleReal)param_.getValue("preferences:idview:z_intensity"));
918
tolerance->setValue((DoubleReal)param_.getValue("preferences:idview:tolerance"));
920
relative_loss_intensity->setValue((DoubleReal)param_.getValue("preferences:idview:relative_loss_intensity"));
921
max_isotopes->setValue((Int)param_.getValue("preferences:idview:max_isotope"));
922
charge->setValue((Int)param_.getValue("preferences:idview:charge"));
926
showLogMessage_(LS_ERROR,"", "String 'A-ions' doesn't exist in identification dialog.");
929
Qt::CheckState state = param_.getValue("preferences:idview:show_a_ions").toBool() == true ? Qt::Checked : Qt::Unchecked;
930
a_ions[0]->setCheckState(state);
935
showLogMessage_(LS_ERROR,"", "String 'B-ions' doesn't exist in identification dialog.");
938
Qt::CheckState state = param_.getValue("preferences:idview:show_b_ions").toBool() == true ? Qt::Checked : Qt::Unchecked;
939
b_ions[0]->setCheckState(state);
944
showLogMessage_(LS_ERROR,"", "String 'C-ions' doesn't exist in identification dialog.");
947
Qt::CheckState state = param_.getValue("preferences:idview:show_c_ions").toBool() == true ? Qt::Checked : Qt::Unchecked;
948
c_ions[0]->setCheckState(state);
953
showLogMessage_(LS_ERROR,"", "String 'X-ions' doesn't exist in identification dialog.");
956
Qt::CheckState state = param_.getValue("preferences:idview:show_x_ions").toBool() == true ? Qt::Checked : Qt::Unchecked;
957
x_ions[0]->setCheckState(state);
962
showLogMessage_(LS_ERROR,"", "String 'Y-ions' doesn't exist in identification dialog.");
965
Qt::CheckState state = param_.getValue("preferences:idview:show_y_ions").toBool() == true ? Qt::Checked : Qt::Unchecked;
966
y_ions[0]->setCheckState(state);
971
showLogMessage_(LS_ERROR,"", "String 'Z-ions' doesn't exist in identification dialog.");
974
Qt::CheckState state = param_.getValue("preferences:idview:show_z_ions").toBool() == true ? Qt::Checked : Qt::Unchecked;
975
z_ions[0]->setCheckState(state);
980
showLogMessage_(LS_ERROR,"", "String 'Precursor' doesn't exist in identification dialog.");
983
Qt::CheckState state = param_.getValue("preferences:idview:show_precursor").toBool() == true ? Qt::Checked : Qt::Unchecked;
984
pc_ions[0]->setCheckState(state);
989
showLogMessage_(LS_ERROR,"", "String 'Neutral losses' doesn't exist in identification dialog.");
992
Qt::CheckState state = param_.getValue("preferences:idview:add_losses").toBool() == true ? Qt::Checked : Qt::Unchecked;
993
nl_ions[0]->setCheckState(state);
998
showLogMessage_(LS_ERROR,"", "String 'Isotope clusters' doesn't exist in identification dialog.");
1001
Qt::CheckState state = param_.getValue("preferences:idview:add_isotopes").toBool() == true ? Qt::Checked : Qt::Unchecked;
1002
ic_ions[0]->setCheckState(state);
1007
showLogMessage_(LS_ERROR,"", "String 'Abundant immonium-ions' doesn't exist in identification dialog.");
1010
Qt::CheckState state = param_.getValue("preferences:idview:add_abundant_immonium_ions").toBool() == true ? Qt::Checked : Qt::Unchecked;
1011
ai_ions[0]->setCheckState(state);
1014
if(is_relative_tolerance == 0)
1016
showLogMessage_(LS_ERROR,"", "String 'unit is ppm' doesn't exist in identification dialog.");
1019
Qt::CheckState state = param_.getValue("preferences:idview:is_relative_tolerance").toBool() == true ? Qt::Checked : Qt::Unchecked;
1020
is_relative_tolerance->setCheckState(state);
1023
// --------------------------------------------------------------------
1024
// Execute dialog and update parameter object with user modified values
1027
param_.setValue("preferences:default_path", default_path->text());
1028
if (default_path_current->isChecked())
1030
param_.setValue("preferences:default_path_current","true");
1034
param_.setValue("preferences:default_path_current","false");
1036
param_.setValue("preferences:tmp_file_path", temp_path->text());
1037
param_.setValue("preferences:number_of_recent_files", recent_files->value());
1038
param_.setValue("preferences:default_map_view", map_default->currentText());
1039
param_.setValue("preferences:intensity_cutoff", map_cutoff->currentText());
1040
param_.setValue("preferences:on_file_change", on_file_change->currentText());
1042
param_.setValue("preferences:db:host",db_host->text());
1043
param_.setValue("preferences:db:port",db_port->value());
1044
param_.setValue("preferences:db:name",db_name->text());
1045
param_.setValue("preferences:db:login",db_login->text());
1046
param_.remove("DBPassword");
1048
param_.setValue("preferences:1d:peak_color",color_1D->getColor().name());
1049
param_.setValue("preferences:1d:highlighted_peak_color",selected_1D->getColor().name());
1050
param_.setValue("preferences:1d:icon_color",icon_1D->getColor().name());
1052
param_.setValue("preferences:2d:dot:gradient",peak_2D->gradient().toString());
1053
param_.setValue("preferences:2d:mapping_of_mz_to",mapping_2D->currentText());
1054
param_.setValue("preferences:2d:dot:feature_icon",feature_icon_2D->currentText());
1055
param_.setValue("preferences:2d:dot:feature_icon_size",feature_icon_size_2D->value());
1057
param_.setValue("preferences:3d:dot:gradient",peak_3D->gradient().toString());
1058
param_.setValue("preferences:3d:dot:shade_mode", shade_3D->currentIndex());
1059
param_.setValue("preferences:3d:dot:line_width",line_width_3D->value());
1062
param_.setValue("preferences:idview:a_intensity", a_intensity->value(), "Default intensity of a-ions");
1063
param_.setValue("preferences:idview:b_intensity", b_intensity->value(), "Default intensity of b-ions");
1064
param_.setValue("preferences:idview:c_intensity", c_intensity->value(), "Default intensity of c-ions");
1065
param_.setValue("preferences:idview:x_intensity", x_intensity->value(), "Default intensity of x-ions");
1066
param_.setValue("preferences:idview:y_intensity", y_intensity->value(), "Default intensity of y-ions");
1067
param_.setValue("preferences:idview:z_intensity", z_intensity->value(), "Default intensity of z-ions");
1068
param_.setValue("preferences:idview:relative_loss_intensity", relative_loss_intensity->value(), "Relativ loss in percent");
1069
param_.setValue("preferences:idview:max_isotope", max_isotopes->value(), "Maximum number of isotopes");
1070
param_.setValue("preferences:idview:charge", charge->value(), "Charge state");
1071
param_.setValue("preferences:idview:tolerance", tolerance->value(), "Alignment tolerance");
1074
a_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1075
param_.setValue("preferences:idview:show_a_ions", checked, "Show a-ions");
1077
b_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1078
param_.setValue("preferences:idview:show_b_ions", checked, "Show b-ions");
1080
c_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1081
param_.setValue("preferences:idview:show_c_ions", checked, "Show c-ions");
1083
x_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1084
param_.setValue("preferences:idview:show_x_ions", checked, "Show x-ions");
1086
y_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1087
param_.setValue("preferences:idview:show_y_ions", checked, "Show y-ions");
1089
z_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1090
param_.setValue("preferences:idview:show_z_ions", checked, "Show z-ions");
1092
pc_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1093
param_.setValue("preferences:idview:show_precursor", checked, "Show precursor");
1095
nl_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1096
param_.setValue("preferences:idview:add_losses", checked, "Show neutral losses");
1098
ic_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1099
param_.setValue("preferences:idview:add_isotopes", checked, "Show isotopes");
1101
ai_ions[0]->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1102
param_.setValue("preferences:idview:add_abundant_immonium_ions", checked, "Show abundant immonium ions");
1104
is_relative_tolerance->checkState() == Qt::Checked ? checked = "true" : checked = "false";
1105
param_.setValue("preferences:idview:is_relative_tolerance", checked, "Use ppm instead of Da for the automatic alignment");
1110
std::set<String> TOPPViewBase::getFilenamesOfOpenFiles_()
1112
set<String> filename_set;
1113
// iterate over all windows
1114
QWidgetList wl = ws_->windowList();
1115
for(int i=0; i!=ws_->windowList().count(); ++i)
1118
// iterate over all widgets
1119
const SpectrumWidget* sw = qobject_cast<const SpectrumWidget*>(w);
1122
Size lc = sw->canvas()->getLayerCount();
1123
// iterate over all layers
1124
for (Size j=0; j!= lc; ++j)
1126
filename_set.insert(sw->canvas()->getLayer(j).filename);
1130
return filename_set;
1133
void TOPPViewBase::addDataFile(const String& filename, bool show_options, bool add_to_recent, String caption, UInt window_id, Size spectrum_id)
1135
setCursor(Qt::WaitCursor);
1137
String abs_filename = File::absolutePath(filename);
1139
// check if the file exists
1140
if (!File::exists(abs_filename))
1142
showLogMessage_(LS_ERROR, "Open file error",String("The file '") + abs_filename + "' does not exist!");
1143
setCursor(Qt::ArrowCursor);
1147
// determine file type
1149
FileTypes::Type file_type = fh.getType(abs_filename);
1150
if (file_type == FileTypes::UNKNOWN)
1152
showLogMessage_(LS_ERROR,"Open file error",String("Could not determine file type of '") + abs_filename + "'!");
1153
setCursor(Qt::ArrowCursor);
1157
// abort if file type unsupported
1158
if (file_type == FileTypes::INI)
1160
showLogMessage_(LS_ERROR,"Open file error",String("The type '") + fh.typeToName(file_type) + "' is not supported!");
1161
setCursor(Qt::ArrowCursor);
1165
//try to load data and determine if it's 1D or 2D data
1167
// create shared pointer to main data types
1168
FeatureMapType* feature_map = new FeatureMapType();
1169
FeatureMapSharedPtrType feature_map_sptr(feature_map);
1171
ExperimentType* peak_map = new ExperimentType();
1172
ExperimentSharedPtrType peak_map_sptr(peak_map);
1174
ConsensusMapType* consensus_map = new ConsensusMapType();
1175
ConsensusMapSharedPtrType consensus_map_sptr(consensus_map);
1177
vector<PeptideIdentification> peptides;
1179
LayerData::DataType data_type;
1183
if (file_type == FileTypes::FEATUREXML)
1185
FeatureXMLFile().load(abs_filename, *feature_map);
1186
data_type = LayerData::DT_FEATURE;
1188
else if (file_type == FileTypes::CONSENSUSXML)
1190
ConsensusXMLFile().load(abs_filename, *consensus_map);
1191
data_type = LayerData::DT_CONSENSUS;
1193
else if (file_type == FileTypes::IDXML)
1195
vector<ProteinIdentification> proteins; // not needed later
1196
IdXMLFile().load(abs_filename, proteins, peptides);
1197
data_type = LayerData::DT_IDENT;
1201
fh.loadExperiment(abs_filename, *peak_map, file_type, ProgressLogger::GUI);
1202
data_type = LayerData::DT_CHROMATOGRAM;
1203
if (TOPPViewBase::containsMS1Scans(*peak_map))
1205
data_type = LayerData::DT_PEAK;
1209
catch(Exception::BaseException& e)
1211
showLogMessage_(LS_ERROR,"Error while loading file", e.what());
1212
setCursor(Qt::ArrowCursor);
1216
// sort for mz and update ranges of newly loaded data
1217
peak_map_sptr->sortSpectra(true);
1218
peak_map_sptr->updateRanges(1);
1220
// try to add the data
1223
caption = File::basename(abs_filename);
1230
addData(feature_map_sptr, consensus_map_sptr, peptides, peak_map_sptr, data_type, false, show_options, true, abs_filename, caption, window_id, spectrum_id);
1232
// add to recent file
1235
addRecentFile_(filename);
1238
// watch file contents for changes
1239
watcher_->addFile(abs_filename);
1242
setCursor(Qt::ArrowCursor);
1245
void TOPPViewBase::addData(FeatureMapSharedPtrType feature_map, ConsensusMapSharedPtrType consensus_map, vector<PeptideIdentification>& peptides, ExperimentSharedPtrType peak_map, LayerData::DataType data_type, bool show_as_1d, bool show_options, bool as_new_window, const String& filename, const String& caption, UInt window_id, Size spectrum_id)
1247
// initialize flags with defaults from the parameters
1248
bool maps_as_2d = ((String)param_.getValue("preferences:default_map_view")=="2d");
1249
bool maps_as_1d = false;
1250
bool use_intensity_cutoff = ((String)param_.getValue("preferences:intensity_cutoff")=="on");
1252
// feature, consensus feature and identifications can be merged
1253
bool mergeable = ((data_type == LayerData::DT_FEATURE) ||
1254
(data_type == LayerData::DT_CONSENSUS) ||
1255
(data_type == LayerData::DT_IDENT));
1257
// only one peak spectrum? disable 2D as default
1258
if (peak_map->size() == 1)
1263
// set the window where (new layer) data could be opened in
1264
// get EnhancedTabBarWidget with given id
1265
EnhancedTabBarWidgetInterface* tab_bar_target = window_(window_id);
1267
// cast to SpectrumWidget
1268
SpectrumWidget* target_window = dynamic_cast<SpectrumWidget*>(tab_bar_target);
1270
if (tab_bar_target == 0)
1272
target_window = getActiveSpectrumWidget();
1276
as_new_window = false;
1279
//create dialog no matter if it is shown or not. It is used to determine the flags.
1280
TOPPViewOpenDialog dialog(caption, as_new_window, maps_as_2d, use_intensity_cutoff, this);
1282
//disable opening in new window when there is no active window or feature/ID data is to be opened, but the current window is a 3D window
1283
if (target_window == 0 || (mergeable && dynamic_cast<Spectrum3DWidget*>(target_window) != 0))
1285
dialog.disableLocation(true);
1288
//disable 1d/2d/3d option for feature/consensus/identification maps
1291
dialog.disableDimension(true);
1294
//disable cutoff for feature/consensus/identification maps
1297
dialog.disableCutoff(false);
1300
//enable merge layers if a feature layer is opened and there are already features layers to merge it to
1301
if (mergeable && target_window != 0) //TODO merge
1303
SpectrumCanvas* open_canvas = target_window->canvas();
1304
Map<Size,String> layers;
1305
for (Size i=0; i<open_canvas->getLayerCount(); ++i)
1307
if (data_type == open_canvas->getLayer(i).type)
1309
layers[i] = open_canvas->getLayer(i).name;
1312
dialog.setMergeLayers(layers);
1315
//show options if requested
1316
if (show_options && !dialog.exec())
1320
as_new_window = dialog.openAsNewWindow();
1321
maps_as_2d = dialog.viewMapAs2D();
1322
maps_as_1d = dialog.viewMapAs1D();
1329
use_intensity_cutoff = dialog.isCutoffEnabled();
1330
Int merge_layer = dialog.getMergeLayer();
1332
//determine the window to open the data in
1333
if (as_new_window) //new window
1335
if (maps_as_1d) // 2d in 1d window
1337
target_window = new Spectrum1DWidget(getSpectrumParameters(1), ws_);
1339
else if (maps_as_2d || mergeable) //2d or features/IDs
1341
target_window = new Spectrum2DWidget(getSpectrumParameters(2), ws_);
1345
target_window = new Spectrum3DWidget(getSpectrumParameters(3), ws_);
1349
if (merge_layer == -1) //add layer to the window
1351
if (data_type == LayerData::DT_FEATURE) //features
1353
if (!target_window->canvas()->addLayer(feature_map, filename))
1358
else if (data_type == LayerData::DT_CONSENSUS) //consensus features
1360
if (!target_window->canvas()->addLayer(consensus_map,filename)) return;
1362
else if (data_type == LayerData::DT_IDENT)
1364
if (!target_window->canvas()->addLayer(peptides, filename)) return;
1368
if (!target_window->canvas()->addLayer(peak_map,filename)) return;
1371
if (use_intensity_cutoff)
1373
DoubleReal cutoff = estimateNoiseFromRandomMS1Scans(*(target_window->canvas()->getCurrentLayer().getPeakData()));
1375
DataFilters::DataFilter filter;
1376
filter.field = DataFilters::INTENSITY;
1377
filter.op = DataFilters::GREATER_EQUAL;
1378
filter.value = cutoff;
1380
DataFilters filters;
1381
filters.add(filter);
1382
target_window->canvas()->setFilters(filters);
1383
} else // no mower, hide zeros if wanted
1385
Int n_zeros = TOPPViewBase::countMS1Zeros(*(target_window->canvas()->getCurrentLayer().getPeakData()));
1389
DataFilters::DataFilter filter;
1390
filter.field = DataFilters::INTENSITY;
1391
filter.op = DataFilters::GREATER_EQUAL;
1392
filter.value = 0.001;
1393
QMessageBox::question(this, "Note:", "Data contains zero values.\nA filter will be added to hide these values.\nYou can reenable data points with zero intensity by removing the filter.");
1395
DataFilters filters;
1396
filters.add(filter);
1397
target_window->canvas()->setFilters(filters);
1401
Spectrum1DWidget* open_1d_window = dynamic_cast<Spectrum1DWidget*>(target_window);
1404
open_1d_window->canvas()->activateSpectrum(spectrum_id);
1409
target_window->canvas()->setLayerName(target_window->canvas()->activeLayerIndex(), caption);
1411
else //merge feature/ID data into feature layer
1413
Spectrum2DCanvas* canvas = qobject_cast<Spectrum2DCanvas*>(target_window->canvas());
1414
if (data_type == LayerData::DT_CONSENSUS)
1416
canvas->mergeIntoLayer(merge_layer, consensus_map);
1418
else if (data_type == LayerData::DT_FEATURE)
1420
canvas->mergeIntoLayer(merge_layer, feature_map);
1422
else if (data_type == LayerData::DT_IDENT)
1424
canvas->mergeIntoLayer(merge_layer, peptides);
1430
showSpectrumWidgetInWindow(target_window,caption);
1439
void TOPPViewBase::addRecentFile_(const String& filename)
1441
//find out absolute path
1442
String tmp = File::absolutePath(filename);
1444
// remove the new file if already in the recent list and prepend it
1445
recent_files_.removeAll(tmp.toQString());
1446
recent_files_.prepend(tmp.toQString());
1448
//remove those files exceeding the defined number
1449
UInt number_of_recent_files = UInt(param_.getValue("preferences:number_of_recent_files"));
1450
while ((UInt)recent_files_.size() > number_of_recent_files)
1452
recent_files_.removeLast();
1454
updateRecentMenu_();
1457
void TOPPViewBase::updateRecentMenu_()
1459
// get/correct number of recent files
1460
UInt number_of_recent_files = UInt(param_.getValue("preferences:number_of_recent_files"));
1461
if (number_of_recent_files>20)
1463
number_of_recent_files = 20;
1464
param_.setValue("preferences:number_of_recent_files",20);
1467
for (Size i = 0; i < 20; ++i)
1469
if (i < (UInt)(recent_files_.size()))
1471
recent_actions_[i]->setText(recent_files_[(int)i]);
1472
recent_actions_[i]->setVisible(true);
1476
recent_actions_[i]->setVisible(false);
1481
EnhancedTabBarWidgetInterface* TOPPViewBase::window_(int id) const
1483
// return window with window_id == id
1484
QList<QWidget*> windows = ws_->windowList();
1486
for(int i = 0; i < windows.size(); ++i)
1488
EnhancedTabBarWidgetInterface* w = dynamic_cast<EnhancedTabBarWidgetInterface*>(windows.at(i));
1489
if (w->getWindowId() == id)
1497
void TOPPViewBase::closeByTab(int id)
1499
QWidget* w = dynamic_cast<QWidget*>(window_(id));
1507
void TOPPViewBase::enhancedWorkspaceWindowChanged(int id)
1509
QWidget* w = dynamic_cast<QWidget*>(window_(id));
1513
TOPPASWidget* tw = dynamic_cast<TOPPASWidget*>(w);
1514
SpectrumWidget* sw = dynamic_cast<SpectrumWidget*>(w);
1515
if (tw) // TOPPASWidget
1517
setTOPPASTabEnabled(true);
1518
views_tabwidget_->setCurrentIndex(2);
1519
views_tabwidget_->setTabEnabled(0, false); // switch scan view off
1520
views_tabwidget_->setTabEnabled(1, false); // switch identification view off
1522
else if (sw) // SpectrumWidget
1524
views_tabwidget_->setTabEnabled(0, true);
1526
// check if there is a layer before requesting data from it
1527
if(sw->canvas()->getLayerCount() > 0)
1529
const ExperimentType& map = *sw->canvas()->getCurrentLayer().getPeakData();
1530
if(hasPeptideIdentifications(map))
1532
views_tabwidget_->setTabEnabled(1, true);
1533
if (dynamic_cast<Spectrum2DWidget*>(w))
1535
views_tabwidget_->setCurrentIndex(0); // switch to scan tab for 2D widget
1536
} else if (dynamic_cast<Spectrum1DWidget*>(w))
1538
views_tabwidget_->setCurrentIndex(1); // switch to identification tab for 1D widget
1543
views_tabwidget_->setTabEnabled(1, false);
1544
views_tabwidget_->setCurrentIndex(0); // stay on scan view tab
1546
setTOPPASTabEnabled(false);
1552
void TOPPViewBase::closeFile()
1554
ws_->activeWindow()->close();
1558
void TOPPViewBase::editMetadata()
1560
SpectrumCanvas* canvas = getActiveCanvas();
1562
// warn if hidden layer => wrong layer selected...
1563
if (!canvas->getCurrentLayer().visible)
1565
showLogMessage_(LS_NOTICE,"The current layer is not visible","Have you selected the right layer for this action?");
1568
//show editable meta data dialog
1569
canvas->showMetaData(true);
1572
void TOPPViewBase::layerStatistics()
1574
getActiveSpectrumWidget()->showStatistics();
1578
void TOPPViewBase::showStatusMessage(string msg, OpenMS::UInt time)
1582
message_label_->setText(msg.c_str());
1583
statusBar()->update();
1587
statusBar()->showMessage(msg.c_str(), time);
1589
QApplication::processEvents();
1592
void TOPPViewBase::showCursorStatusInvert(double mz, double rt)
1594
// swap rt vs mz (for vertical projection)
1595
showCursorStatus(rt, mz);
1598
void TOPPViewBase::showCursorStatus(double mz, double rt)
1600
message_label_->setText("");
1603
mz_label_->setText("m/z: ");
1605
else if (boost::math::isinf(mz) || boost::math::isnan(mz))
1607
mz_label_->setText("m/z: n/a");
1611
mz_label_->setText((String("m/z: ")+String::number(mz,6).fillLeft(' ',8)).toQString());
1616
rt_label_->setText("RT: ");
1618
else if (boost::math::isinf(rt) || boost::math::isnan(rt))
1620
rt_label_->setText("RT: n/a");
1624
rt_label_->setText((String("RT: ")+String::number(rt,1).fillLeft(' ',8)).toQString());
1626
statusBar()->update();
1629
void TOPPViewBase::resetZoom()
1631
SpectrumWidget* w = getActiveSpectrumWidget();
1634
w->canvas()->resetZoom();
1638
void TOPPViewBase::setIntensityMode(int index)
1640
SpectrumWidget* w = getActiveSpectrumWidget();
1643
intensity_button_group_->button(index)->setChecked(true);
1644
Spectrum2DWidget* w2d = dynamic_cast<Spectrum2DWidget*>(w);
1645
// 2D widget and intensity mode changed?
1646
if (w2d && w2d->canvas()->getIntensityMode() != index)
1648
if (index == OpenMS::SpectrumCanvas::IM_LOG)
1650
w2d->canvas()->getCurrentLayer().param.setValue("dot:gradient", MultiGradient::getDefaultGradientLogarithmicIntensityMode().toString());
1651
w2d->canvas()->recalculateCurrentLayerDotGradient();
1652
} else if (index != OpenMS::SpectrumCanvas::IM_LOG)
1654
w2d->canvas()->getCurrentLayer().param.setValue("dot:gradient", MultiGradient::getDefaultGradientLinearIntensityMode().toString());
1655
w2d->canvas()->recalculateCurrentLayerDotGradient();
1658
w->setIntensityMode((OpenMS::SpectrumCanvas::IntensityModes)index);
1662
void TOPPViewBase::setDrawMode1D(int index)
1664
Spectrum1DWidget* w = getActive1DWidget();
1667
draw_group_1d_->button(Spectrum1DCanvas::DM_PEAKS)->setChecked(true);
1668
w->canvas()->setDrawMode((OpenMS::Spectrum1DCanvas::DrawModes)index);
1672
void TOPPViewBase::changeLabel(QAction* action)
1676
//label type is selected
1677
for (Size i=0; i<LayerData::SIZE_OF_LABEL_TYPE; ++i)
1679
if (action->text().toStdString() == LayerData::NamesOfLabelType[i])
1681
getActive2DWidget()->canvas()->setLabel(LayerData::LabelType(i));
1686
//button is simply pressed
1689
if (getActive2DWidget()->canvas()->getCurrentLayer().label == LayerData::L_NONE)
1691
getActive2DWidget()->canvas()->setLabel(LayerData::L_INDEX);
1692
dm_label_2d_->menu()->actions()[1]->setChecked(true);
1696
getActive2DWidget()->canvas()->setLabel(LayerData::L_NONE);
1697
dm_label_2d_->menu()->actions()[0]->setChecked(true);
1704
void TOPPViewBase::changeUnassigned(QAction* action)
1708
// mass reference is selected
1709
if (action->text().toStdString() == "Don't show")
1711
getActive2DWidget()->canvas()->setLayerFlag(LayerData::F_UNASSIGNED, false);
1712
getActive2DWidget()->canvas()->setLayerFlag(LayerData::I_PEPTIDEMZ, false);
1715
else if (action->text().toStdString() == "Show by precursor m/z")
1717
getActive2DWidget()->canvas()->setLayerFlag(LayerData::F_UNASSIGNED, true);
1718
getActive2DWidget()->canvas()->setLayerFlag(LayerData::I_PEPTIDEMZ, false);
1721
else if (action->text().toStdString() == "Show by peptide mass")
1723
getActive2DWidget()->canvas()->setLayerFlag(LayerData::F_UNASSIGNED, true);
1724
getActive2DWidget()->canvas()->setLayerFlag(LayerData::I_PEPTIDEMZ, true);
1728
// button is simply pressed
1731
bool previous = getActive2DWidget()->canvas()->getLayerFlag(LayerData::F_UNASSIGNED);
1732
getActive2DWidget()->canvas()->setLayerFlag(LayerData::F_UNASSIGNED,
1734
if (previous) // now: don't show
1736
dm_unassigned_2d_->menu()->actions()[0]->setChecked(true);
1738
else // now: show by precursor
1740
dm_unassigned_2d_->menu()->actions()[1]->setChecked(true);
1742
getActive2DWidget()->canvas()->setLayerFlag(LayerData::I_PEPTIDEMZ, false);
1748
void TOPPViewBase::changeLayerFlag(bool on)
1750
QAction* action = qobject_cast<QAction *>(sender());
1751
if (Spectrum2DWidget* win = getActive2DWidget())
1754
if (action == dm_precursors_2d_)
1756
win->canvas()->setLayerFlag(LayerData::P_PRECURSORS,on);
1759
else if (action == dm_hulls_2d_)
1761
win->canvas()->setLayerFlag(LayerData::F_HULLS,on);
1763
else if (action == dm_hull_2d_)
1765
win->canvas()->setLayerFlag(LayerData::F_HULL,on);
1767
//consensus features
1768
else if (action == dm_elements_2d_)
1770
win->canvas()->setLayerFlag(LayerData::C_ELEMENTS,on);
1773
else if (action == dm_ident_2d_)
1775
win->canvas()->setLayerFlag(LayerData::I_PEPTIDEMZ, on);
1780
void TOPPViewBase::updateToolBar()
1782
SpectrumWidget* w = getActiveSpectrumWidget();
1786
//set intensity mode
1787
if(intensity_button_group_->button(w->canvas()->getIntensityMode()))
1789
intensity_button_group_->button(w->canvas()->getIntensityMode())->setChecked(true);
1792
showLogMessage_(LS_ERROR, __PRETTY_FUNCTION__ ,"Button for intensity mode doesn't exist");
1797
Spectrum1DWidget* w1 = getActive1DWidget();
1801
draw_group_1d_->button(w1->canvas()->getDrawMode())->setChecked(true);
1803
//show/hide toolbars and buttons
1804
tool_bar_1d_->show();
1805
tool_bar_2d_peak_->hide();
1806
tool_bar_2d_feat_->hide();
1807
tool_bar_2d_cons_->hide();
1808
tool_bar_2d_ident_->hide();
1812
Spectrum2DWidget* w2 = getActive2DWidget();
1815
tool_bar_1d_->hide();
1816
// check if there is a layer before requesting data from it
1817
if(w2->canvas()->getLayerCount() > 0)
1820
if (w2->canvas()->getCurrentLayer().type == LayerData::DT_PEAK)
1822
dm_precursors_2d_->setChecked(w2->canvas()->getLayerFlag(LayerData::P_PRECURSORS));
1823
tool_bar_2d_peak_->show();
1824
tool_bar_2d_feat_->hide();
1825
tool_bar_2d_cons_->hide();
1826
tool_bar_2d_ident_->hide();
1828
//feature draw modes
1829
else if (w2->canvas()->getCurrentLayer().type == LayerData::DT_FEATURE)
1831
dm_hulls_2d_->setChecked(w2->canvas()->getLayerFlag(LayerData::F_HULLS));
1832
dm_hull_2d_->setChecked(w2->canvas()->getLayerFlag(LayerData::F_HULL));
1833
dm_unassigned_2d_->setChecked(w2->canvas()->getLayerFlag(LayerData::F_UNASSIGNED));
1834
dm_label_2d_->setChecked(w2->canvas()->getCurrentLayer().label!=LayerData::L_NONE);
1835
tool_bar_2d_peak_->hide();
1836
tool_bar_2d_feat_->show();
1837
tool_bar_2d_cons_->hide();
1838
tool_bar_2d_ident_->hide();
1840
//consensus feature draw modes
1841
else if (w2->canvas()->getCurrentLayer().type == LayerData::DT_CONSENSUS)
1843
dm_elements_2d_->setChecked(w2->canvas()->getLayerFlag(LayerData::C_ELEMENTS));
1844
tool_bar_2d_peak_->hide();
1845
tool_bar_2d_feat_->hide();
1846
tool_bar_2d_cons_->show();
1847
tool_bar_2d_ident_->hide();
1849
else if (w2->canvas()->getCurrentLayer().type == LayerData::DT_IDENT)
1851
dm_ident_2d_->setChecked(w2->canvas()->getLayerFlag(LayerData::I_PEPTIDEMZ));
1852
tool_bar_2d_peak_->hide();
1853
tool_bar_2d_feat_->hide();
1854
tool_bar_2d_cons_->hide();
1855
tool_bar_2d_ident_->show();
1861
Spectrum3DWidget* w3 = getActive3DWidget();
1864
//show/hide toolbars and buttons
1865
tool_bar_1d_->hide();
1866
tool_bar_2d_peak_->hide();
1867
tool_bar_2d_feat_->hide();
1868
tool_bar_2d_cons_->hide();
1869
tool_bar_2d_ident_->hide();
1873
void TOPPViewBase::updateLayerBar()
1876
layer_manager_->clear();
1877
SpectrumCanvas* cc = getActiveCanvas();
1878
if (cc == 0) return;
1880
//determine if this is a 1D view (for text color)
1881
bool is_1d_view = false;
1882
if (dynamic_cast<Spectrum1DCanvas*>(cc)) is_1d_view = true;
1884
layer_manager_->blockSignals(true);
1885
QListWidgetItem* item = 0;
1887
for (Size i = 0; i<cc->getLayerCount(); ++i)
1889
const LayerData& layer = cc->getLayer(i);
1891
item = new QListWidgetItem( layer_manager_ );
1892
name = layer.name.toQString();
1895
name += " [flipped]";
1897
item->setText(name);
1898
if (is_1d_view && cc->getLayerCount()>1)
1901
icon.fill(QColor(layer.param.getValue("peak_color").toQString()));
1902
item->setIcon(icon);
1906
item->setCheckState(Qt::Checked);
1910
item->setCheckState(Qt::Unchecked);
1914
item->setText(item->text() + '*');
1916
//highlight active item
1917
if (i == cc->activeLayerIndex())
1919
layer_manager_->setCurrentItem(item);
1922
layer_manager_->blockSignals(false);
1925
void TOPPViewBase::updateViewBar()
1927
SpectrumCanvas* cc = getActiveCanvas();
1928
int layer_row = layer_manager_->currentRow();
1930
if (layer_row == -1 || cc == 0)
1932
// TODO: we need to clean up the SpectraViewWidget & friends
1936
if (spectra_view_widget_->isVisible())
1938
spectra_view_widget_->updateEntries(cc->getCurrentLayer());
1941
if (spectra_identification_view_widget_->isVisible())
1943
spectra_identification_view_widget_->attachLayer(&cc->getCurrentLayer());
1944
spectra_identification_view_widget_->updateEntries();
1948
void TOPPViewBase::viewChanged(int tab_index)
1950
// notify that behavior will be deactivated
1951
view_behavior_->deactivateBehavior();
1954
if (views_tabwidget_->tabText(tab_index) == "Scan view")
1956
layer_dock_widget_->show();
1957
filter_dock_widget_->show();
1958
view_behavior_ = spectraview_behavior_;
1959
} else if (views_tabwidget_->tabText(tab_index) == "Identification view")
1961
layer_dock_widget_->show();
1962
filter_dock_widget_->show();
1963
if (getActive2DWidget()) // currently 2D window is open
1965
showSpectrumAs1D(0);
1967
view_behavior_ = identificationview_behavior_;
1968
} else if (views_tabwidget_->tabText(tab_index) == "TOPPAS view")
1970
layer_dock_widget_->hide();
1971
filter_dock_widget_->hide();
1972
// no complex behavior for TOPPAS view needed
1975
cerr << "Error: tab_index " << tab_index << endl;
1976
throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
1979
// notify that new behavior has been activated
1980
view_behavior_->activateBehavior();
1985
void TOPPViewBase::updateDataBar()
1987
const set<String> filenames = getFilenamesOfOpenFiles();
1989
data_manager_view_->clear();
1990
data_manager_view_->blockSignals(true);
1991
QTreeWidgetItem* item = 0;
1992
for (set<String>::const_iterator it = filenames.begin(); it != filenames.end(); ++it)
1994
item = new QTreeWidgetItem(data_manager_view_);
1995
QString name = it->toQString();
1997
item->setText(0, fi.fileName());
1999
layer_manager_->blockSignals(false);
2002
void TOPPViewBase::layerSelectionChange(int i)
2006
getActiveCanvas()->activateLayer(i);
2012
void TOPPViewBase::layerContextMenu(const QPoint & pos)
2014
QListWidgetItem* item = layer_manager_->itemAt(pos);
2017
QAction* new_action = 0;
2018
int layer = layer_manager_->row(item);
2019
QMenu* context_menu = new QMenu(layer_manager_);
2020
context_menu->addAction("Rename");
2021
context_menu->addAction("Delete");
2023
if (getActiveCanvas()->getLayer(layer).flipped)
2025
new_action = context_menu->addAction("Flip upwards (1D)");
2029
new_action = context_menu->addAction("Flip downwards (1D)");
2031
if (!getActive1DWidget())
2033
new_action->setEnabled(false);
2036
context_menu->addSeparator();
2037
context_menu->addAction("Preferences");
2039
QAction* selected = context_menu->exec(layer_manager_->mapToGlobal(pos));
2041
if (selected!=0 && selected->text()=="Delete")
2043
getActiveCanvas()->removeLayer(layer);
2046
else if (selected!=0 && selected->text()=="Rename")
2048
QString name = QInputDialog::getText(this,"Rename layer","Name:");
2051
getActiveCanvas()->setLayerName(layer, name);
2054
// flip layer up/downwards
2055
else if (selected != 0 && selected->text() == "Flip downwards (1D)")
2057
getActive1DWidget()->canvas()->flipLayer(layer);
2058
getActive1DWidget()->canvas()->setMirrorModeActive(true);
2060
else if (selected != 0 && selected->text() == "Flip upwards (1D)")
2062
getActive1DWidget()->canvas()->flipLayer(layer);
2063
bool b = getActive1DWidget()->canvas()->flippedLayersExist();
2064
getActive1DWidget()->canvas()->setMirrorModeActive(b);
2066
else if (selected != 0 && selected->text() == "Preferences")
2068
getActiveCanvas()->showCurrentLayerPreferences();
2071
//Update tab bar and window title
2072
if (getActiveCanvas()->getLayerCount()!=0)
2074
tab_bar_->setTabText(tab_bar_->currentIndex(), getActiveCanvas()->getLayer(0).name.toQString());
2075
getActiveSpectrumWidget()->setWindowTitle(getActiveCanvas()->getLayer(0).name.toQString());
2079
tab_bar_->setTabText(tab_bar_->currentIndex(),"empty");
2080
getActiveSpectrumWidget()->setWindowTitle("empty");
2083
//Update filter bar, spectrum bar and layer bar
2089
delete (context_menu);
2093
void TOPPViewBase::logContextMenu(const QPoint & pos)
2095
QMenu* context_menu = new QMenu(log_);
2096
context_menu->addAction("Clear");
2098
QAction* selected = context_menu->exec(log_->mapToGlobal(pos));
2101
if (selected != 0 && selected->text()== "Clear")
2105
delete (context_menu);
2108
void TOPPViewBase::filterContextMenu(const QPoint & pos)
2110
//do nothing if no window is open
2111
if (getActiveCanvas()==0) return;
2113
//do nothing if no layer is loaded into the canvas
2114
if (getActiveCanvas()->getLayerCount() == 0) return;
2116
QMenu* context_menu = new QMenu(filters_);
2118
//warn if the current layer is not visible
2119
String layer_name = String("Layer: ") + getActiveCanvas()->getCurrentLayer().name;
2120
if (!getActiveCanvas()->getCurrentLayer().visible)
2122
layer_name += " (invisible)";
2124
context_menu->addAction(layer_name.toQString())->setEnabled(false);
2125
context_menu->addSeparator();
2128
QListWidgetItem* item = filters_->itemAt(pos);
2131
context_menu->addAction("Edit");
2132
context_menu->addAction("Delete");
2136
context_menu->addAction("Add filter");
2139
QAction* selected = context_menu->exec(filters_->mapToGlobal(pos));
2142
if(selected->text()=="Delete")
2144
DataFilters filters = getActiveCanvas()->getCurrentLayer().filters;
2145
filters.remove(filters_->row(item));
2146
getActiveCanvas()->setFilters(filters);
2149
else if (selected->text()=="Edit")
2153
else if (selected->text()=="Add filter")
2155
DataFilters filters = getActiveCanvas()->getCurrentLayer().filters;
2156
DataFilters::DataFilter filter;
2157
DataFilterDialog dlg(filter, this);
2160
filters.add(filter);
2161
getActiveCanvas()->setFilters(filters);
2166
delete (context_menu);
2169
void TOPPViewBase::filterEdit(QListWidgetItem* item)
2171
DataFilters filters = getActiveCanvas()->getCurrentLayer().filters;
2172
DataFilters::DataFilter filter = filters[filters_->row(item)];
2173
DataFilterDialog dlg(filter, this);
2176
filters.replace(filters_->row(item),filter);
2177
getActiveCanvas()->setFilters(filters);
2182
void TOPPViewBase::layerEdit(QListWidgetItem* /*item*/)
2184
getActiveCanvas()->showCurrentLayerPreferences();
2187
void TOPPViewBase::updateFilterBar()
2192
SpectrumCanvas* canvas = getActiveCanvas();
2193
if (canvas==0) return;
2194
if (canvas->getLayerCount()==0) return;
2196
const DataFilters& filters = getActiveCanvas()->getCurrentLayer().filters;
2197
for (Size i=0; i<filters.size(); ++i)
2199
QListWidgetItem* item = new QListWidgetItem(filters_);
2200
item->setText(filters[i].toString().toQString());
2204
filters_check_box_->setChecked(getActiveCanvas()->getCurrentLayer().filters.isActive());
2207
void TOPPViewBase::layerFilterVisibilityChange(bool on)
2209
if (getActiveCanvas())
2211
getActiveCanvas()->changeLayerFilterState(getActiveCanvas()->activeLayerIndex(),on);
2215
void TOPPViewBase::layerVisibilityChange(QListWidgetItem* item)
2219
layer = layer_manager_->row(item);
2220
visible = getActiveCanvas()->getLayer(layer).visible;
2222
if (item->checkState()==Qt::Unchecked && visible)
2224
getActiveCanvas()->changeVisibility(layer, false);
2226
else if (item->checkState()==Qt::Checked && !visible)
2228
getActiveCanvas()->changeVisibility(layer, true);
2232
void TOPPViewBase::updateTabBar(QWidget* w)
2236
EnhancedTabBarWidgetInterface* tbw = dynamic_cast<EnhancedTabBarWidgetInterface*>(w);
2237
Int window_id = tbw->getWindowId();
2238
tab_bar_->setCurrentId(window_id);
2242
void TOPPViewBase::tileVertical()
2244
// primitive horizontal tiling
2245
QWidgetList windows = ws_->windowList();
2246
if ( !windows.count() ) return;
2248
if (getActive1DWidget()) getActive1DWidget()->showNormal();
2249
if (getActive2DWidget()) getActive2DWidget()->showNormal();
2251
int heightForEach = ws_->height() / windows.count();
2253
for ( int i = 0; i < int(windows.count()); ++i )
2255
QWidget *window = windows.at(i);
2256
if ( window->isMaximized() || window->isFullScreen() )
2260
window->setWindowState(Qt::WindowNoState);
2263
int preferredHeight = window->minimumHeight()+window->parentWidget()->baseSize().height();
2264
int actHeight = std::max(heightForEach, preferredHeight);
2266
window->parentWidget()->setGeometry( 0, y, ws_->width(), actHeight );
2271
void TOPPViewBase::tileHorizontal()
2273
// primitive horizontal tiling
2274
QWidgetList windows = ws_->windowList();
2275
if ( !windows.count() ) return;
2277
if (getActive1DWidget()) getActive1DWidget()->showNormal();
2278
if (getActive2DWidget()) getActive2DWidget()->showNormal();
2280
int widthForEach = ws_->width() / windows.count();
2282
for ( int i = 0; i < int(windows.count()); ++i )
2284
QWidget *window = windows.at(i);
2285
if ( window->windowState() & Qt::WindowMaximized )
2289
window->showNormal();
2291
int preferredWidth = window->minimumWidth()+window->parentWidget()->baseSize().width();
2293
int actWidth = std::max(widthForEach, preferredWidth);
2295
window->parentWidget()->setGeometry( y, 0, actWidth , ws_->height() );
2300
void TOPPViewBase::layerActivated()
2304
updateCurrentPath();
2307
void TOPPViewBase::layerDeactivated()
2312
void TOPPViewBase::showSpectrumWidgetInWindow(SpectrumWidget* sw, const String& caption)
2315
connect(sw->canvas(),SIGNAL(preferencesChange()),this,SLOT(updateLayerBar()));
2316
connect(sw->canvas(),SIGNAL(layerActivated(QWidget*)),this,SLOT(layerActivated()));
2317
connect(sw->canvas(),SIGNAL(layerModficationChange(Size,bool)),this,SLOT(updateLayerBar()));
2318
connect(sw,SIGNAL(sendStatusMessage(std::string,OpenMS::UInt)),this,SLOT(showStatusMessage(std::string,OpenMS::UInt)));
2319
connect(sw,SIGNAL(sendCursorStatus(double,double)),this,SLOT(showCursorStatus(double,double)));
2320
connect(sw,SIGNAL(dropReceived(const QMimeData*,QWidget*,int)),this,SLOT(copyLayer(const QMimeData*,QWidget*,int)));
2322
// 1D spectrum specific signals
2323
Spectrum1DWidget* sw1 = qobject_cast<Spectrum1DWidget*>(sw);
2326
connect(sw1, SIGNAL(showCurrentPeaksAs2D()), this, SLOT(showCurrentPeaksAs2D()));
2327
connect(sw1, SIGNAL(showCurrentPeaksAs3D()), this, SLOT(showCurrentPeaksAs3D()));
2330
// 2D spectrum specific signals
2331
Spectrum2DWidget* sw2 = qobject_cast<Spectrum2DWidget*>(sw);
2334
connect(sw2->getHorizontalProjection(),SIGNAL(sendCursorStatus(double,double)),this,SLOT(showCursorStatus(double,double)));
2335
connect(sw2->getVerticalProjection(),SIGNAL(sendCursorStatus(double,double)),this,SLOT(showCursorStatusInvert(double,double)));
2336
connect(sw2, SIGNAL(showSpectrumAs1D(int)), this, SLOT(showSpectrumAs1D(int)));
2337
connect(sw2, SIGNAL(showCurrentPeaksAs3D()), this, SLOT(showCurrentPeaksAs3D()));
2340
// 3D spectrum specific signals
2341
Spectrum3DWidget* sw3 = qobject_cast<Spectrum3DWidget*>(sw);
2344
connect(sw3, SIGNAL(showCurrentPeaksAs2D()), this, SLOT(showCurrentPeaksAs2D()));
2347
sw->setWindowTitle(caption.toQString());
2350
static int window_counter = 4711;
2352
sw->setWindowId(window_counter++);
2354
tab_bar_->addTab(caption.toQString(), sw->getWindowId());
2356
//connect slots and sigals for removing the widget from the bar, when it is closed
2357
//- through the menu entry
2358
//- through the tab bar
2359
//- thourgh the MDI close button
2360
connect(sw,SIGNAL(aboutToBeDestroyed(int)),tab_bar_,SLOT(removeId(int)));
2362
tab_bar_->setCurrentId(sw->getWindowId());
2364
//show first window maximized (only visible windows are in the list)
2365
if (ws_->windowList().count()==0)
2367
sw->showMaximized();
2373
enhancedWorkspaceWindowChanged(sw->getWindowId());
2376
void TOPPViewBase::showGoToDialog()
2378
SpectrumWidget* w = getActiveSpectrumWidget();
2381
getActiveSpectrumWidget()->showGoToDialog();
2385
void TOPPViewBase::activate1DSpectrum(int index)
2387
Spectrum1DWidget* w = getActive1DWidget();
2390
view_behavior_->activate1DSpectrum(index);
2394
void TOPPViewBase::deactivate1DSpectrum(int index)
2396
Spectrum1DWidget* w = getActive1DWidget();
2399
view_behavior_->deactivate1DSpectrum(index);
2403
EnhancedWorkspace* TOPPViewBase::getWorkspace() const
2408
SpectrumWidget* TOPPViewBase::getActiveSpectrumWidget() const
2410
if (!ws_->activeWindow())
2414
return qobject_cast<SpectrumWidget*>(ws_->activeWindow());
2417
SpectrumCanvas* TOPPViewBase::getActiveCanvas() const
2419
SpectrumWidget* sw = qobject_cast<SpectrumWidget*>(ws_->activeWindow());
2424
return sw->canvas();
2428
TOPPASWidget* TOPPViewBase::getActiveTOPPASWidget() const
2430
if (!ws_->activeWindow())
2434
return qobject_cast<TOPPASWidget*>(ws_->activeWindow());
2437
Spectrum1DWidget* TOPPViewBase::getActive1DWidget() const
2439
Spectrum1DWidget* w = qobject_cast<Spectrum1DWidget*>(getActiveSpectrumWidget());
2447
Spectrum2DWidget* TOPPViewBase::getActive2DWidget() const
2449
Spectrum2DWidget* w = qobject_cast<Spectrum2DWidget*>(getActiveSpectrumWidget());
2457
Spectrum3DWidget* TOPPViewBase::getActive3DWidget() const
2459
Spectrum3DWidget* w = qobject_cast<Spectrum3DWidget*>(getActiveSpectrumWidget());
2467
void TOPPViewBase::loadPreferences(String filename)
2469
// compose default ini file path
2470
String default_ini_file = String(QDir::homePath()) + "/.TOPPView.ini";
2474
filename = default_ini_file;
2477
// load preferences, if file exists
2478
if (File::exists(filename))
2483
{ // the file might be corrupt
2491
//apply preferences if they are of the current TOPPView version
2492
if(!error && tmp.exists("preferences:version") &&
2493
tmp.getValue("preferences:version").toString() == VersionInfo::getVersion())
2499
catch (Exception::InvalidParameter& /*e*/)
2509
//set parameters to defaults when something is fishy with the parameters file
2512
//reset parameters (they will be stored again when TOPPView quits)
2513
setParameters(Param());
2515
cerr << "The TOPPView preferences files '" << filename << "' was ignored. It is no longer compatible with this TOPPView version and will be replaced." << endl;
2518
else if (filename != default_ini_file)
2520
cerr << "Unable to load INI File: '" << filename << "'" << endl;
2522
param_.setValue("PreferencesFile" , filename);
2524
//set the recent files
2525
Param p = param_.copy("preferences:RecentFiles");
2528
for (Param::ParamIterator it=p.begin() ; it!=p.end() ; ++it)
2530
QString filename = it->value.toQString();
2531
if (File::exists(filename)) recent_files_.append(filename);
2535
updateRecentMenu_();
2538
void TOPPViewBase::savePreferences()
2540
// replace recent files
2541
param_.removeAll("preferences:RecentFiles");
2543
for (int i = 0; i < recent_files_.size(); ++i)
2545
param_.setValue("preferences:RecentFiles:"+String(i),recent_files_[i]);
2549
param_.setValue("preferences:version",VersionInfo::getVersion());
2551
//save only the subsection that begins with "preferences:"
2554
param_.copy("preferences:").store(string(param_.getValue("PreferencesFile")));
2556
catch(Exception::UnableToCreateFile& /*e*/)
2558
cerr << "Unable to create INI File: '" << string(param_.getValue("PreferencesFile")) << "'" << endl;
2562
void TOPPViewBase::openRecentFile()
2564
QAction* action = qobject_cast<QAction *>(sender());
2567
QString filename = action->text();
2568
if (filename.endsWith(".toppas", Qt::CaseInsensitive))
2570
addTOPPASFile(filename, true);
2574
addDataFile(filename, true, true);
2579
QStringList TOPPViewBase::getFileList_(const String& path_overwrite)
2581
String filter_all = "readable files (*.mzML *.mzXML *.mzData *.featureXML *.consensusXML *.idXML *.dta *.dta2d fid *.bz2 *.gz *.toppas);;";
2582
String filter_single = "mzML files (*.mzML);;mzXML files (*.mzXML);;mzData files (*.mzData);;feature map (*.featureXML);;consensus feature map (*.consensusXML);;peptide identifications (*.idXML);;XML files (*.xml);;XMass Analysis (fid);;dta files (*.dta);;dta2d files (*.dta2d);;bzipped files (*.bz2);;gzipped files (*.gz);;TOPPAS files (*.toppas);;all files (*)";
2584
QString open_path = current_path_.toQString();
2585
if (path_overwrite!="")
2587
open_path = path_overwrite.toQString();
2589
// we use the QT file dialog instead of using QFileDialog::Names(...)
2590
// On Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog,
2591
// which prevents us from doing GUI testing on it.
2592
QFileDialog dialog(this, "Open file(s)", open_path, (filter_all + filter_single).toQString());
2593
dialog.setFileMode(QFileDialog::ExistingFiles);
2594
QStringList file_names;
2598
file_names = dialog.selectedFiles();
2604
void TOPPViewBase::openFileDialog()
2606
QStringList files = getFileList_();
2607
for(QStringList::iterator it = files.begin(); it!=files.end(); ++it)
2609
QString filename = *it;
2610
if (filename.endsWith(".toppas", Qt::CaseInsensitive))
2612
addTOPPASFile(filename, true);
2616
addDataFile(filename, true, true);
2621
void TOPPViewBase::addTOPPASFile(const String& file_name, bool in_new_window)
2623
TOPPASScene* scene = 0;
2624
if (in_new_window) // open in new window
2626
// create TOPPASWidget, load data and open in new window
2627
TOPPASWidget* tw = new TOPPASWidget(Param(), ws_, toppas_tmp_path_);
2628
showTOPPipelineInWindow_(tw, File::basename(file_name));
2629
scene = tw->getScene();
2630
scene->load(file_name);
2631
addRecentFile_(file_name);
2633
else // merge into existing scene
2635
TOPPASWidget* tw = getActiveTOPPASWidget();
2640
// create TOPPASWidget, load data into temporary scene and include into existing one
2641
TOPPASScene* tmp_scene = new TOPPASScene(0, File::getTempDirectory().toQString()+QDir::separator(), false);
2642
tmp_scene->load(file_name);
2643
scene = tw->getScene();
2644
scene->include(tmp_scene);
2650
// connect scene signals only if we created a new window (otherwise they already exist)
2651
connect(scene, SIGNAL(saveMe()), this, SLOT(savePipeline()));
2652
connect(scene, SIGNAL(selectionCopied(TOPPASScene*)), this, SLOT(saveToClipboard(TOPPASScene*)));
2653
connect(scene, SIGNAL(requestClipboardContent()), this, SLOT(sendClipboardContent()));
2654
connect(scene, SIGNAL(mainWindowNeedsUpdate()), this, SLOT(updateMenu()));
2655
connect(scene, SIGNAL(openInTOPPView(QStringList)), this, SLOT(openFilesInTOPPView(QStringList)));
2658
//connect vertex signals/slots for log messages
2659
for (TOPPASScene::VertexIterator it = scene->verticesBegin(); it != scene->verticesEnd(); ++it)
2661
TOPPASToolVertex* tv = qobject_cast<TOPPASToolVertex*>(*it);
2664
connect(tv, SIGNAL(toolStarted()), this, SLOT(toolStarted()));
2665
connect(tv, SIGNAL(toolFinished()), this, SLOT(toolFinished()));
2666
connect(tv, SIGNAL(toolCrashed()), this, SLOT(toolCrashed()));
2667
connect(tv, SIGNAL(toolFailed()), this, SLOT(toolFailed()));
2668
connect(tv, SIGNAL(toppOutputReady(const QString&)), this, SLOT(updateTOPPOutputLog(const QString&)));
2671
TOPPASOutputFileListVertex* oflv = qobject_cast<TOPPASOutputFileListVertex*>(*it);
2674
connect (oflv, SIGNAL(outputFileWritten(const String&)), this, SLOT(outputVertexFinished(const String&)));
2680
void TOPPViewBase::showTOPPipelineInWindow_(TOPPASWidget* tw, const String& caption)
2684
connect(tw,SIGNAL(sendStatusMessage(std::string,OpenMS::UInt)),this,SLOT(showStatusMessage(std::string,OpenMS::UInt)));
2685
connect(tw,SIGNAL(sendCursorStatus(double,double)),this,SLOT(showCursorStatus(double,double)));
2686
connect(tw,SIGNAL(toolDroppedOnWidget(double,double)),this,SLOT(insertNewVertex_(double,double)));
2687
connect(tw,SIGNAL(pipelineDroppedOnWidget(const String&, bool)),this,SLOT(addTOPPASFile(const String&, bool)));
2689
tw->setWindowTitle(caption.toQString());
2692
static int window_counter = 1337;
2693
tw->setWindowId(window_counter);
2696
//connect slots and signals for removing the widget from the bar, when it is closed
2697
//- through the menu entry
2698
//- through the tab bar
2699
//- through the MDI close button
2700
connect(tw, SIGNAL(aboutToBeDestroyed(int)),tab_bar_,SLOT(removeId(int)));
2702
//show first window maximized (only visible windows are in the list)
2703
if (ws_->windowList().count()==0)
2705
tw->showMaximized();
2711
TOPPASScene* ts = tw->getScene();
2713
connect (ts, SIGNAL(entirePipelineFinished()), this, SLOT(showPipelineFinishedLogMessage()));
2714
connect (ts, SIGNAL(entirePipelineFinished()), this, SLOT(updateMenu()));
2715
connect (ts, SIGNAL(pipelineExecutionFailed()), this, SLOT(updateMenu()));
2717
ts->setSceneRect((tw->mapToScene(tw->rect())).boundingRect());
2719
tab_bar_->addTab(caption.toQString(), tw->getWindowId());
2720
tab_bar_->setCurrentId(tw->getWindowId());
2721
enhancedWorkspaceWindowChanged(tw->getWindowId());
2724
void TOPPViewBase::insertNewVertex_(double x, double y, QTreeWidgetItem* item)
2726
// get toppas tree view from tab widget 2
2727
TOPPASTreeView* toppas_tree_view = qobject_cast<TOPPASTreeView*>(views_tabwidget_->widget(2));
2729
if (!getActiveTOPPASWidget() || !getActiveTOPPASWidget()->getScene() || !toppas_tree_view)
2734
TOPPASScene* scene = getActiveTOPPASWidget()->getScene();
2735
QTreeWidgetItem* current_tool = item ? item : toppas_tree_view->currentItem();
2736
String tool_name = String(current_tool->text(0));
2737
TOPPASVertex* tv = 0;
2739
if (tool_name == "<Input files>")
2741
tv = new TOPPASInputFileListVertex();
2743
else if (tool_name == "<Output files>")
2745
tv = new TOPPASOutputFileListVertex();
2746
TOPPASOutputFileListVertex* oflv = qobject_cast<TOPPASOutputFileListVertex*>(tv);
2747
connect (oflv, SIGNAL(outputFileWritten(const String&)), this, SLOT(outputVertexFinished(const String&)));
2748
scene->connectOutputVertexSignals(oflv);
2750
else if (tool_name == "<Merger>")
2752
tv = new TOPPASMergerVertex(true);
2754
else if (tool_name == "<Collector>")
2756
tv = new TOPPASMergerVertex(false);
2758
else // node is a TOPP tool
2760
if (current_tool->childCount() > 0)
2762
// category or tool name with types is selected (instead of a concrete type)
2766
if (current_tool->parent() != 0 && current_tool->parent()->parent() != 0)
2768
// selected item is a type
2769
tool_type = String(current_tool->text(0));
2770
tool_name = String(current_tool->parent()->text(0));
2774
// normal tool which does not have type selected
2775
tool_name = String(current_tool->text(0));
2779
tv = new TOPPASToolVertex(tool_name, tool_type);
2780
TOPPASToolVertex* ttv = qobject_cast<TOPPASToolVertex*>(tv);
2781
connect (ttv, SIGNAL(toolStarted()), this, SLOT(toolStarted()));
2782
connect (ttv, SIGNAL(toolFinished()), this, SLOT(toolFinished()));
2783
connect (ttv, SIGNAL(toolCrashed()), this, SLOT(toolCrashed()));
2784
connect (ttv, SIGNAL(toolFailed()), this, SLOT(toolFailed()));
2785
connect (ttv, SIGNAL(toppOutputReady(const QString&)), this, SLOT(updateTOPPOutputLog(const QString&)));
2787
scene->connectToolVertexSignals(ttv);
2790
scene->connectVertexSignals(tv);
2791
scene->addVertex(tv);
2793
tv->setZValue(toppas_z_value_);
2794
toppas_z_value_ += 0.000001;
2796
scene->setChanged(true);
2799
void TOPPViewBase::insertNewVertexInCenter_(QTreeWidgetItem* item)
2801
TOPPASTreeView* toppas_tree_view = qobject_cast<TOPPASTreeView*>(views_tabwidget_->widget(2));
2803
if (!getActiveTOPPASWidget() || !getActiveTOPPASWidget()->getScene() || !toppas_tree_view || !toppas_tree_view->currentItem())
2808
QPointF insert_pos = getActiveTOPPASWidget()->mapToScene(QPoint((getActiveTOPPASWidget()->width()/2.0)+(qreal)(5*toppas_node_offset_),(getActiveTOPPASWidget()->height()/2.0)+(qreal)(5*toppas_node_offset_)));
2809
insertNewVertex_(insert_pos.x(), insert_pos.y(), item);
2810
toppas_node_offset_ = (toppas_node_offset_+1) % 10;
2813
void TOPPViewBase::openExampleDialog()
2815
QStringList files = getFileList_(File::getOpenMSDataPath() + "/examples/");
2817
for(QStringList::iterator it = files.begin(); it != files.end(); ++it)
2819
QString filename = *it;
2820
if (filename.endsWith(".toppas", Qt::CaseInsensitive))
2822
addTOPPASFile(filename, true);
2826
addDataFile(filename, true, true);
2831
void TOPPViewBase::connectToDB_(DBConnection& db)
2833
//get the password if unset
2834
if (!param_.exists("DBPassword"))
2837
ss << "Enter password for user '" << (String)param_.getValue("preferences:db:login") << "' at '"<< (String)param_.getValue("preferences:db:host")<<":"<<(String)param_.getValue("preferences:db:port")<<"' : ";
2839
QString text = QInputDialog::getText(this, "TOPPView database password", ss.str().c_str(), QLineEdit::Password,QString::null, &ok);
2842
param_.setValue("DBPassword",text);
2846
if (param_.exists("DBPassword"))
2850
db.connect((String)param_.getValue("preferences:db:name"), (String)param_.getValue("preferences:db:login"),(String)param_.getValue("DBPassword"),(String)param_.getValue("preferences:db:host"),(UInt)param_.getValue("preferences:db:port"));
2852
catch (DBConnection::InvalidQuery& er)
2854
param_.remove("DBPassword");
2855
showLogMessage_(LS_ERROR,"Unable to log in to the database server",String("Check the login data in the preferences!\nDatabase error message: ") + er.what());
2860
void TOPPViewBase::openDatabaseDialog()
2864
if (db.isConnected())
2866
vector<UInt> result;
2867
DBOpenDialog db_dialog(db,result,this);
2868
if (db_dialog.exec())
2871
for (vector<UInt>::iterator it = result.begin();it!=result.end();++it)
2873
addDataDB(*it, true);
2879
void TOPPViewBase::rerunTOPPTool()
2881
//warn if hidden layer => wrong layer selected...
2882
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
2885
showLogMessage_(LS_NOTICE,"The current layer is not visible","Have you selected the right layer for this action?");
2888
//delete old input and output file
2889
File::remove(topp_.file_name + "_in");
2890
File::remove(topp_.file_name + "_out");
2896
void TOPPViewBase::showTOPPDialog()
2898
QAction* action = qobject_cast<QAction*>(sender());
2899
showTOPPDialog_(action->data().toBool());
2902
void TOPPViewBase::showTOPPDialog_(bool visible)
2904
//warn if hidden layer => wrong layer selected...
2905
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
2908
showLogMessage_(LS_NOTICE,"The current layer is not visible","Have you selected the right layer for this action?");
2911
//create and store unique file name prefix for files
2912
topp_.file_name = param_.getValue("preferences:tmp_file_path").toString() + "/TOPPView_" + File::getUniqueName();
2913
if (!File::writable(topp_.file_name+"_ini"))
2915
showLogMessage_(LS_ERROR,"Cannot create temporary file",String("Cannot write to '")+topp_.file_name+"'_ini!");
2918
ToolsDialog tools_dialog(this,topp_.file_name+"_ini",current_path_,getCurrentLayer()->type);
2920
if(tools_dialog.exec()==QDialog::Accepted)
2922
//Store tool name, input parameter and output parameter
2923
topp_.tool = tools_dialog.getTool();
2924
topp_.in = tools_dialog.getInput();
2925
topp_.out = tools_dialog.getOutput();
2926
topp_.visible = visible;
2932
void TOPPViewBase::runTOPPTool_()
2934
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
2936
//test if files are writable
2937
if (!File::writable(topp_.file_name+"_in"))
2939
showLogMessage_(LS_ERROR,"Cannot create temporary file",String("Cannot write to '")+topp_.file_name+"_in'!");
2942
if (!File::writable(topp_.file_name+"_out"))
2944
showLogMessage_(LS_ERROR,"Cannot create temporary file",String("Cannot write to '")+topp_.file_name+"'_out!");
2949
topp_.layer_name = layer.name;
2950
topp_.window_id = getActiveSpectrumWidget()->getWindowId();
2951
topp_.spectrum_id = layer.getCurrentSpectrumIndex();
2952
if (layer.type==LayerData::DT_PEAK)
2955
f.setLogType(ProgressLogger::GUI);
2959
getActiveCanvas()->getVisiblePeakData(exp);
2960
f.store(topp_.file_name+"_in",exp);
2964
f.store(topp_.file_name+"_in",*layer.getPeakData());
2967
else if (layer.type==LayerData::DT_FEATURE)
2972
getActiveCanvas()->getVisibleFeatureData(map);
2973
FeatureXMLFile().store(topp_.file_name+"_in",map);
2977
FeatureXMLFile().store(topp_.file_name+"_in",*layer.getFeatureMap());
2984
ConsensusMapType map;
2985
getActiveCanvas()->getVisibleConsensusData(map);
2986
ConsensusXMLFile().store(topp_.file_name+"_in",map);
2990
ConsensusXMLFile().store(topp_.file_name+"_in",*layer.getConsensusMap());
2994
//compose argument list
2997
<< (topp_.file_name + "_ini").toQString()
2998
<< QString("-%1").arg(topp_.in.toQString())
2999
<< (topp_.file_name + "_in").toQString()
3003
args << QString("-%1").arg(topp_.out.toQString())
3004
<< (topp_.file_name+"_out").toQString();
3007
//start log and show it
3008
showLogMessage_(LS_NOTICE,"Starting TOPP tool","");// tool + args.join(" "));
3011
topp_.process = new QProcess();
3012
topp_.process->setProcessChannelMode(QProcess::MergedChannels);
3013
connect(topp_.process,SIGNAL(readyReadStandardOutput()),this,SLOT(updateProcessLog()));
3014
topp_.process->start(topp_.tool.toQString(),args);
3016
//connect the finished slot
3017
connect(topp_.process,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(finishTOPPToolExecution(int,QProcess::ExitStatus)));
3020
topp_.process->waitForStarted();
3024
void TOPPViewBase::finishTOPPToolExecution(int, QProcess::ExitStatus)
3026
//finish with new line
3029
String tmp_dir = param_.getValue("preferences:tmp_file_path").toString();
3031
if (topp_.process->exitStatus()==QProcess::CrashExit)
3033
showLogMessage_(LS_ERROR,"Execution of TOPP tool not successful!",String("The tool crashed during execution. If you want to debug this crash, check the input files in '") + tmp_dir + "' or enable 'debug' mode in the TOPP ini file.");
3035
else if(topp_.out!="")
3037
if (!File::readable(topp_.file_name+"_out"))
3039
showLogMessage_(LS_ERROR,"Cannot read TOPP output",String("Cannot read '")+topp_.file_name+"_out'!");
3043
addDataFile(topp_.file_name+"_out",true,false, topp_.layer_name + " (" + topp_.tool + ")", topp_.window_id, topp_.spectrum_id);
3048
delete topp_.process;
3052
//clean up temporary files
3053
if (param_.getValue("preferences:topp_cleanup")=="true")
3055
File::remove(topp_.file_name+"_ini");
3056
File::remove(topp_.file_name+"_in");
3057
File::remove(topp_.file_name+"_out");
3061
const LayerData* TOPPViewBase::getCurrentLayer() const
3063
SpectrumCanvas* canvas = getActiveCanvas();
3068
return &(canvas->getCurrentLayer());
3071
void TOPPViewBase::toggleProjections()
3073
Spectrum2DWidget* w = getActive2DWidget();
3076
//update minimum size before
3077
if (!w->projectionsVisible())
3079
setMinimumSize(700,700);
3083
setMinimumSize(400,400);
3085
w->toggleProjections();
3089
void TOPPViewBase::annotateWithID()
3091
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
3092
//warn if hidden layer => wrong layer selected...
3095
showLogMessage_(LS_NOTICE,"The current layer is not visible","Have you selected the right layer for this action?");
3099
QString name = QFileDialog::getOpenFileName(this,
3100
"Select protein identification data",
3101
current_path_.toQString(),
3102
"idXML files (*.idXML);; all files (*.*)");
3106
vector<PeptideIdentification> identifications;
3107
vector<ProteinIdentification> protein_identifications;
3112
IdXMLFile().load(name, protein_identifications, identifications, document_id);
3114
catch (Exception::BaseException& e)
3116
QMessageBox::warning(this, "Error", QString("Loading of idXML file failed! (") + e.what() + ")");
3121
if (layer.type==LayerData::DT_PEAK)
3123
Param p = mapper.getDefaults();
3124
p.setValue("rt_tolerance", 0.1, "RT tolerance (in seconds) for the matching");
3125
p.setValue("mz_tolerance", 1.0, "m/z tolerance (in ppm or Da) for the matching");
3126
p.setValue("mz_measure", "Da", "unit of 'mz_tolerance' (ppm or Da)");
3127
mapper.setParameters(p);
3128
mapper.annotate(*layer.getPeakData(), identifications, protein_identifications);
3129
views_tabwidget_->setTabEnabled(1, true); // enable identification view
3131
else if (layer.type==LayerData::DT_FEATURE)
3133
mapper.annotate(*layer.getFeatureMap(), identifications, protein_identifications);
3137
mapper.annotate(*layer.getConsensusMap(), identifications, protein_identifications);
3143
void TOPPViewBase::showSpectrumGenerationDialog()
3145
TheoreticalSpectrumGenerationDialog spec_gen_dialog;
3146
if (spec_gen_dialog.exec())
3148
String seq_string(spec_gen_dialog.line_edit->text());
3149
if (seq_string == "")
3151
QMessageBox::warning(this, "Error", "You must enter a peptide sequence!");
3154
AASequence aa_sequence;
3157
aa_sequence.setStringSequence(seq_string);
3159
catch (Exception::BaseException& e)
3161
QMessageBox::warning(this, "Error", QString("Spectrum generation failed! (") + e.what() + ")");
3164
Int charge = spec_gen_dialog.spin_box->value();
3166
if (aa_sequence.isValid())
3168
RichPeakSpectrum rich_spec;
3169
TheoreticalSpectrumGenerator generator;
3172
p.setValue("add_metainfo", "true", "Adds the type of peaks as metainfo to the peaks, like y8+, [M-H2O+2H]++");
3174
bool losses = (spec_gen_dialog.list_widget->item(7)->checkState() == Qt::Checked); // "Neutral losses"
3175
String losses_str = losses ? "true" : "false";
3176
p.setValue("add_losses", losses_str, "Adds common losses to those ion expect to have them, only water and ammonia loss is considered");
3178
bool isotopes = (spec_gen_dialog.list_widget->item(8)->checkState() == Qt::Checked); // "Isotope clusters"
3179
String iso_str = isotopes ? "true" : "false";
3180
p.setValue("add_isotopes", iso_str, "If set to 1 isotope peaks of the product ion peaks are added");
3182
bool abundant_immonium_ions = (spec_gen_dialog.list_widget->item(9)->checkState() == Qt::Checked); // "abundant immonium-ions"
3183
String abundant_immonium_ions_str = abundant_immonium_ions ? "true" : "false";
3184
p.setValue("add_abundant_immonium_ions", abundant_immonium_ions_str, "Add most abundant immonium ions");
3186
Size max_iso_count = (Size)spec_gen_dialog.max_iso_spinbox->value();
3187
p.setValue("max_isotope", max_iso_count, "Number of isotopic peaks");
3188
p.setValue("a_intensity", spec_gen_dialog.a_intensity->value(), "Intensity of the a-ions");
3189
p.setValue("b_intensity", spec_gen_dialog.b_intensity->value(), "Intensity of the b-ions");
3190
p.setValue("c_intensity", spec_gen_dialog.c_intensity->value(), "Intensity of the c-ions");
3191
p.setValue("x_intensity", spec_gen_dialog.x_intensity->value(), "Intensity of the x-ions");
3192
p.setValue("y_intensity", spec_gen_dialog.y_intensity->value(), "Intensity of the y-ions");
3193
p.setValue("z_intensity", spec_gen_dialog.z_intensity->value(), "Intensity of the z-ions");
3194
DoubleReal rel_loss_int = (DoubleReal)(spec_gen_dialog.rel_loss_intensity->value()) / 100.0;
3195
p.setValue("relative_loss_intensity", rel_loss_int, "Intensity of loss ions, in relation to the intact ion intensity");
3196
generator.setParameters(p);
3200
if (spec_gen_dialog.list_widget->item(0)->checkState() == Qt::Checked) // "A-ions"
3202
generator.addPeaks(rich_spec, aa_sequence, Residue::AIon, charge);
3204
if (spec_gen_dialog.list_widget->item(1)->checkState() == Qt::Checked) // "B-ions"
3206
generator.addPeaks(rich_spec, aa_sequence, Residue::BIon, charge);
3208
if (spec_gen_dialog.list_widget->item(2)->checkState() == Qt::Checked) // "C-ions"
3210
generator.addPeaks(rich_spec, aa_sequence, Residue::CIon, charge);
3212
if (spec_gen_dialog.list_widget->item(3)->checkState() == Qt::Checked) // "X-ions"
3214
generator.addPeaks(rich_spec, aa_sequence, Residue::XIon, charge);
3216
if (spec_gen_dialog.list_widget->item(4)->checkState() == Qt::Checked) // "Y-ions"
3218
generator.addPeaks(rich_spec, aa_sequence, Residue::YIon, charge);
3220
if (spec_gen_dialog.list_widget->item(5)->checkState() == Qt::Checked) // "Z-ions"
3222
generator.addPeaks(rich_spec, aa_sequence, Residue::ZIon, charge);
3224
if (spec_gen_dialog.list_widget->item(6)->checkState() == Qt::Checked) // "Precursor"
3226
generator.addPrecursorPeaks(rich_spec, aa_sequence, charge);
3228
if (spec_gen_dialog.list_widget->item(9)->checkState() == Qt::Checked) // "abundant Immonium-ions"
3230
generator.addAbundantImmoniumIons(rich_spec);
3233
catch (Exception::BaseException& e)
3235
QMessageBox::warning(this, "Error", QString("Spectrum generation failed! (") + e.what() + "). Please report this to the developers (specify what input you used)!");
3239
// convert rich spectrum to simple spectrum
3240
PeakSpectrum new_spec;
3241
for (RichPeakSpectrum::Iterator it = rich_spec.begin(); it != rich_spec.end(); ++it)
3243
new_spec.push_back(static_cast<Peak1D>(*it));
3247
new_exp.push_back(new_spec);
3248
ExperimentSharedPtrType new_exp_sptr(new PeakMap(new_exp));
3249
FeatureMapSharedPtrType f_dummy(new FeatureMapType());
3250
ConsensusMapSharedPtrType c_dummy(new ConsensusMapType());
3251
vector<PeptideIdentification> p_dummy;
3252
addData(f_dummy, c_dummy, p_dummy, new_exp_sptr, LayerData::DT_CHROMATOGRAM, false, true, true, "", seq_string + QString(" (theoretical)"));
3254
// ensure spectrum is drawn as sticks
3255
draw_group_1d_->button(Spectrum1DCanvas::DM_PEAKS)->setChecked(true);
3256
setDrawMode1D(Spectrum1DCanvas::DM_PEAKS);
3261
QMessageBox::warning(this, "Error", "The entered peptide sequence is invalid!");
3266
void TOPPViewBase::showSpectrumAlignmentDialog()
3268
Spectrum1DWidget* active_1d_window = getActive1DWidget();
3269
if (!active_1d_window || !active_1d_window->canvas()->mirrorModeActive())
3273
Spectrum1DCanvas* cc = active_1d_window->canvas();
3275
SpectrumAlignmentDialog spec_align_dialog(active_1d_window);
3276
if (spec_align_dialog.exec())
3278
Int layer_index_1 = spec_align_dialog.get1stLayerIndex();
3279
Int layer_index_2 = spec_align_dialog.get2ndLayerIndex();
3281
// two layers must be selected:
3282
if (layer_index_1 < 0 || layer_index_2 < 0)
3284
QMessageBox::information(this, "Layer selection invalid", "You must select two layers for an alignment.");
3289
DoubleReal tolerance = spec_align_dialog.tolerance_spinbox->value();
3290
param.setValue("tolerance", tolerance, "Defines the absolut (in Da) or relative (in ppm) mass tolerance");
3291
String unit_is_ppm = spec_align_dialog.ppm->isChecked() ? "true" : "false";
3292
param.setValue("is_relative_tolerance", unit_is_ppm, "If true, the mass tolerance is interpreted as ppm value otherwise in Dalton");
3294
active_1d_window->performAlignment((UInt)layer_index_1, (UInt)layer_index_2, param);
3296
DoubleReal al_score = cc->getAlignmentScore();
3297
Size al_size = cc->getAlignmentSize();
3299
QMessageBox::information(this, "Alignment performed", QString("Aligned %1 pairs of peaks (Score: %2).").arg(al_size).arg(al_score));
3303
void TOPPViewBase::showSpectrumAs1D(int index)
3305
Spectrum1DWidget* widget_1d = getActive1DWidget();
3306
Spectrum2DWidget* widget_2d = getActive2DWidget();
3310
if (spectra_view_widget_->isVisible())
3312
spectraview_behavior_->showSpectrumAs1D(index);
3315
if (spectra_identification_view_widget_->isVisible())
3317
identificationview_behavior_->showSpectrumAs1D(index);
3319
} else if (widget_2d)
3321
if (spectra_view_widget_->isVisible())
3323
spectraview_behavior_->showSpectrumAs1D(index);
3326
if (spectra_identification_view_widget_->isVisible())
3328
identificationview_behavior_->showSpectrumAs1D(index);
3334
void TOPPViewBase::showCurrentPeaksAs2D()
3336
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
3337
ExperimentSharedPtrType exp_sptr = layer.getPeakData();
3339
//open new 2D widget
3340
Spectrum2DWidget* w = new Spectrum2DWidget(getSpectrumParameters(2), ws_);
3343
if (!w->canvas()->addLayer(exp_sptr, layer.filename))
3348
String caption = layer.name;
3349
w->canvas()->setLayerName(w->canvas()->activeLayerIndex(), caption);
3350
showSpectrumWidgetInWindow(w, caption);
3357
void TOPPViewBase::showCurrentPeaksAs3D()
3359
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
3361
if (layer.type == LayerData::DT_PEAK)
3363
//open new 3D widget
3364
Spectrum3DWidget* w = new Spectrum3DWidget(getSpectrumParameters(3), ws_);
3366
ExperimentSharedPtrType exp_sptr = getActiveCanvas()->getCurrentLayer().getPeakData();
3368
if (!w->canvas()->addLayer(exp_sptr, layer.filename))
3373
if (getActive1DWidget()) // switch from 1D to 3D
3376
//- doesnt make sense for fragment scan
3377
//- build new Area with mz range equal to 1D visible range
3378
//- rt range either overall MS1 data range or some convenient window
3380
} else if (getActive2DWidget()) // switch from 2D to 3D
3382
w->canvas()->setVisibleArea(getActiveCanvas()->getVisibleArea());
3386
String caption = layer.name + " (3D)";
3387
w->canvas()->setLayerName(w->canvas()->activeLayerIndex(), caption);
3388
showSpectrumWidgetInWindow(w, caption);
3390
// set intensity mode (after spectrum has been added!)
3391
setIntensityMode(SpectrumCanvas::IM_SNAP);
3400
showLogMessage_(LS_NOTICE,"Wrong layer type","You cannot open feature data in 3D mode.");
3404
void TOPPViewBase::showAboutDialog()
3406
//dialog and grid layout
3407
QDialog* dlg = new QDialog(this);
3408
QGridLayout* grid = new QGridLayout(dlg);
3409
dlg->setWindowTitle("About TOPPView");
3412
QLabel* label = new QLabel(dlg);
3413
label->setPixmap(QPixmap(":/TOPP_about.png"));
3414
grid->addWidget(label,0,0);
3417
QString text = QString("<BR>"
3418
"<FONT size=+3>TOPPView</font><BR>"
3422
"OpenMS and TOPP is free software available under the<BR>"
3423
"Lesser GNU Public License (LGPL)<BR>"
3429
"Any published work based on TOPP and OpenMS shall cite these papers:<BR>"
3430
"Sturm et al., BMC Bioinformatics (2008), 9, 163<BR>"
3431
"Kohlbacher et al., Bioinformatics (2007), 23:e191-e197<BR>"
3432
).arg(VersionInfo::getVersion().toQString());
3433
label = new QLabel(text,dlg);
3434
grid->addWidget(label,0,1,Qt::AlignTop | Qt::AlignLeft);
3437
QPushButton* button = new QPushButton("Close",dlg);
3438
grid->addWidget(button,1,1,Qt::AlignBottom | Qt::AlignRight);
3439
connect(button,SIGNAL(clicked()),dlg,SLOT(close()));
3445
void TOPPViewBase::updateProcessLog()
3447
//show log if there is output
3448
qobject_cast<QWidget *>(log_->parent())->show();
3451
log_->append(topp_.process->readAllStandardOutput());
3454
Param TOPPViewBase::getSpectrumParameters(UInt dim)
3456
Param out = param_.copy(String("preferences:") + dim + "d:",true);
3457
out.setValue("default_path",param_.getValue("preferences:default_path").toString());
3461
void TOPPViewBase::abortTOPPTool()
3465
//block signals to avoid error message from finished() signal
3466
topp_.process->blockSignals(true);
3467
//kill and delete the process
3468
topp_.process->terminate();
3469
delete topp_.process;
3472
//finish log with new line
3479
void TOPPViewBase::updateMenu()
3481
//is there a canvas?
3482
bool canvas_exists = false;
3483
if (getActiveCanvas()!=0)
3485
canvas_exists = true;
3488
bool layer_exists = false;
3489
if (canvas_exists && getActiveCanvas()->getLayerCount()!=0)
3491
layer_exists = true;
3493
//is there a TOPP tool running
3494
bool topp_running = false;
3495
if (topp_.process!=0)
3497
topp_running = true;
3500
TOPPASWidget* tw = getActiveTOPPASWidget();
3501
TOPPASScene* ts = 0;
3504
ts = tw->getScene();
3505
} else // active widget is no TOPPAS widget
3510
bool mirror_mode = getActive1DWidget() && getActive1DWidget()->canvas()->mirrorModeActive();
3511
QList<QAction*> actions = this->findChildren<QAction*>("");
3512
for (int i=0; i<actions.count(); ++i)
3514
QString text = actions[i]->text();
3515
if (text=="&Close" || text=="Show/hide grid lines" || text=="Show/hide axis legends")
3517
actions[i]->setEnabled(false);
3520
actions[i]->setEnabled(true);
3523
else if (text.left(15)=="Apply TOPP tool")
3525
actions[i]->setEnabled(false);
3526
if (canvas_exists && layer_exists && !topp_running)
3528
actions[i]->setEnabled(true);
3531
else if (text=="Abort running TOPP tool")
3533
actions[i]->setEnabled(false);
3536
actions[i]->setEnabled(true);
3539
else if (text=="Rerun TOPP tool")
3541
actions[i]->setEnabled(false);
3542
if (canvas_exists && layer_exists && !topp_running && topp_.tool!="")
3544
actions[i]->setEnabled(true);
3547
else if (text=="&Go to" || text=="&Edit meta data" || text=="&Statistics" || text=="&Annotate with identification" || text=="Save all data" || text=="Save visible data" || text=="Preferences")
3549
actions[i]->setEnabled(false);
3550
if (canvas_exists && layer_exists)
3552
actions[i]->setEnabled(true);
3555
else if (text=="Align spectra")
3557
actions[i]->setEnabled(false);
3560
actions[i]->setEnabled(true);
3563
else if (text=="&Run (F5)") // pipeline menu
3566
if (ts && !(ts->isPipelineRunning()))
3570
actions[i]->setEnabled(show);
3572
else if (text=="&Abort") // pipeline menu
3575
if (ts && ts->isPipelineRunning())
3579
actions[i]->setEnabled(show);
3581
else if (text=="&Include TOPPAS pipeline") // pipeline menu
3584
actions[i]->setEnabled(show);
3586
else if (text=="&Load TOPPAS resource file") // pipeline menu
3589
actions[i]->setEnabled(show);
3591
else if (text=="Save TOPPAS &resource file") // pipeline menu
3594
actions[i]->setEnabled(show);
3596
else if (text=="&Save TOPPAS pipeline")
3598
bool show = ts && ts->wasChanged();
3599
actions[i]->setEnabled(show);
3601
else if (text=="Save TOPPAS pipeline &As")
3603
bool show = ts && ts->wasChanged();
3604
actions[i]->setEnabled(show);
3606
else if (text=="Refresh TOPPAS ¶meters") // pipeline menu
3608
bool show = ts && !(ts->isPipelineRunning());
3609
actions[i]->setEnabled(show);
3613
actions[i]->setEnabled(false);
3614
if (canvas_exists && layer_exists)
3616
actions[i]->setEnabled(true);
3622
void TOPPViewBase::loadFiles(const StringList& list, QSplashScreen* splash_screen)
3624
bool last_was_plus = false;
3625
for (StringList::const_iterator it=list.begin(); it!=list.end(); ++it)
3629
last_was_plus = true;
3632
else if (*it=="@bw")
3634
if ( (getActive2DWidget()!=0 || getActive3DWidget()!=0) && getActiveCanvas()!=0 )
3636
Param tmp = getActiveCanvas()->getCurrentLayer().param;
3637
tmp.setValue("dot:gradient", "Linear|0,#ffffff;100,#000000");
3638
getActiveCanvas()->setCurrentLayerParameters(tmp);
3641
else if (*it=="@bg")
3643
if ( (getActive2DWidget()!=0 || getActive3DWidget()!=0) && getActiveCanvas()!=0 )
3645
Param tmp = getActiveCanvas()->getCurrentLayer().param;
3646
tmp.setValue("dot:gradient", "Linear|0,#dddddd;100,#000000");
3647
getActiveCanvas()->setCurrentLayerParameters(tmp);
3652
if ( (getActive2DWidget()!=0 || getActive3DWidget()!=0) && getActiveCanvas()!=0 )
3654
Param tmp = getActiveCanvas()->getCurrentLayer().param;
3655
tmp.setValue("dot:gradient", "Linear|0,#000000;100,#000000");
3656
getActiveCanvas()->setCurrentLayerParameters(tmp);
3661
if ( (getActive2DWidget()!=0 || getActive3DWidget()!=0) && getActiveCanvas()!=0 )
3663
Param tmp = getActiveCanvas()->getCurrentLayer().param;
3664
tmp.setValue("dot:gradient", "Linear|0,#ff0000;100,#ff0000");
3665
getActiveCanvas()->setCurrentLayerParameters(tmp);
3670
if ( (getActive2DWidget()!=0 || getActive3DWidget()!=0) && getActiveCanvas()!=0 )
3672
Param tmp = getActiveCanvas()->getCurrentLayer().param;
3673
tmp.setValue("dot:gradient", "Linear|0,#00ff00;100,#00ff00");
3674
getActiveCanvas()->setCurrentLayerParameters(tmp);
3679
if ( (getActive2DWidget()!=0 || getActive3DWidget()!=0) && getActiveCanvas()!=0 )
3681
Param tmp = getActiveCanvas()->getCurrentLayer().param;
3682
tmp.setValue("dot:gradient", "Linear|0,#ff00ff;100,#ff00ff");
3683
getActiveCanvas()->setCurrentLayerParameters(tmp);
3686
else if (!last_was_plus || !getActiveSpectrumWidget())
3688
splash_screen->showMessage((String("Loading file: ") + *it).toQString());
3689
splash_screen->repaint();
3690
QApplication::processEvents();
3691
addDataFile(*it, false, true); // add data file but don't show options
3695
splash_screen->showMessage((String("Loading file: ") + *it).toQString());
3696
splash_screen->repaint();
3697
QApplication::processEvents();
3698
last_was_plus = false;
3699
addDataFile(*it, false, true,"",getActiveSpectrumWidget()->getWindowId());
3704
void TOPPViewBase::showLogMessage_(TOPPViewBase::LogState state, const String& heading, const String& body)
3706
//Compose current time string
3707
DateTime d = DateTime::now();
3709
String state_string;
3712
case LS_NOTICE: state_string = "NOTICE"; break;
3713
case LS_WARNING: state_string = "WARNING"; break;
3714
case LS_ERROR: state_string = "ERROR"; break;
3718
log_->append("==============================================================================");
3719
log_->append((d.getTime() + " " + state_string + ": " + heading).toQString());
3720
log_->append(body.toQString());
3722
//show log tool window
3723
qobject_cast<QWidget *>(log_->parent())->show();
3726
void TOPPViewBase::saveLayerAll()
3728
getActiveCanvas()->saveCurrentLayer(false);
3731
void TOPPViewBase::saveLayerVisible()
3733
getActiveCanvas()->saveCurrentLayer(true);
3736
void TOPPViewBase::toggleGridLines()
3738
getActiveCanvas()->showGridLines(!getActiveCanvas()->gridLinesShown());
3741
void TOPPViewBase::toggleAxisLegends()
3743
getActiveSpectrumWidget()->showLegend(!getActiveSpectrumWidget()->isLegendShown());
3746
void TOPPViewBase::showPreferences()
3748
getActiveCanvas()->showCurrentLayerPreferences();
3751
void TOPPViewBase::metadataFileDialog()
3753
QStringList files = getFileList_();
3755
fh.getOptions().setMetadataOnly(true);
3756
for (QStringList::iterator it = files.begin(); it!=files.end(); ++it)
3761
fh.loadExperiment(*it,exp);
3763
catch (Exception::BaseException& e)
3765
QMessageBox::critical(this,"Error",(String("Error while reading data: ")+e.what()).c_str());
3768
MetaDataBrowser dlg(false, this);
3774
void TOPPViewBase::metadataDatabaseDialog()
3778
if (con.isConnected())
3781
DBOpenDialog db_dialog(con,ids,ws_);
3782
if (db_dialog.exec())
3785
db.getOptions().setMetadataOnly(true);
3786
for (vector<UInt>::iterator it = ids.begin();it!=ids.end();++it)
3791
db.loadExperiment(*it, exp);
3793
catch (Exception::BaseException& e)
3795
QMessageBox::critical(this,"Error",(String("Error while reading data: ")+e.what()).c_str());
3798
MetaDataBrowser dlg(false, this);
3806
SpectraIdentificationViewWidget* TOPPViewBase::getSpectraIdentificationViewWidget()
3808
return spectra_identification_view_widget_;
3811
void TOPPViewBase::showSpectrumMetaData(int spectrum_index)
3813
getActiveCanvas()->showMetaData(true, spectrum_index);
3816
void TOPPViewBase::copyLayer(const QMimeData* data, QWidget* source, int id)
3818
QTreeWidget* spectra_view_treewidget = spectra_view_widget_->getTreeWidget();
3821
//NOT USED RIGHT NOW, BUT KEEP THIS CODE (it was hard to find out how this is done)
3822
//decode data to get the row
3823
//QByteArray encoded_data = data->data(data->formats()[0]);
3824
//QDataStream stream(&encoded_data, QIODevice::ReadOnly);
3826
//stream >> row >> col;
3829
setCursor(Qt::WaitCursor);
3831
//determine where to copy the data
3833
if (id != -1) new_id = id;
3835
if (source == layer_manager_)
3837
//only the selected row can be dragged => the source layer is the selected layer
3838
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
3840
//attach feature, consensus and peak data
3841
FeatureMapSharedPtrType features = layer.getFeatureMap();
3842
ExperimentSharedPtrType peaks = layer.getPeakData();
3843
ConsensusMapSharedPtrType consensus = layer.getConsensusMap();
3844
vector<PeptideIdentification> peptides = layer.peptides;
3847
addData(features, consensus, peptides, peaks, layer.type, false, false, true, layer.filename, layer.name, new_id);
3849
else if (source == spectra_view_treewidget)
3851
const LayerData& layer = getActiveCanvas()->getCurrentLayer();
3852
QTreeWidgetItem* item = spectra_view_treewidget->currentItem();
3855
Size index = (Size)(item->text(3).toInt());
3856
const ExperimentType::SpectrumType spectrum = (*layer.getPeakData())[index];
3857
ExperimentType new_exp;
3858
new_exp.push_back(spectrum);
3859
ExperimentSharedPtrType new_exp_sptr(new ExperimentType(new_exp));
3860
FeatureMapSharedPtrType f_dummy(new FeatureMapType());
3861
ConsensusMapSharedPtrType c_dummy(new ConsensusMapType());
3862
vector<PeptideIdentification> p_dummy;
3863
addData(f_dummy, c_dummy, p_dummy, new_exp_sptr, LayerData::DT_CHROMATOGRAM, false, false, true, layer.filename, layer.name, new_id);
3866
else if (source == 0)
3868
// drag source is external
3869
if (data->hasUrls())
3871
QList<QUrl> urls = data->urls();
3872
for (QList<QUrl>::const_iterator it = urls.begin(); it != urls.end(); ++it)
3874
addDataFile(it->toLocalFile(), false, true, "", new_id);
3880
catch(Exception::BaseException& e)
3882
showLogMessage_(LS_ERROR,"Error while creating layer",e.what());
3886
setCursor(Qt::ArrowCursor);
3890
void TOPPViewBase::updateCurrentPath()
3892
//do not update if the user disabled this feature.
3893
if (param_.getValue("preferences:default_path_current")!="true") return;
3896
current_path_ = param_.getValue("preferences:default_path");
3898
//update if the current layer has a path associated
3899
if (getActiveCanvas() && getActiveCanvas()->getLayerCount()!=0 && getActiveCanvas()->getCurrentLayer().filename!="")
3901
current_path_ = File::path(getActiveCanvas()->getCurrentLayer().filename);
3905
void TOPPViewBase::showSpectrumBrowser()
3907
views_dockwidget_->show();
3911
void TOPPViewBase::fileChanged_(const String& filename)
3913
// check if file has been deleted
3914
if (!QFileInfo(filename.toQString()).exists())
3916
watcher_->removeFile(filename);
3920
QWidgetList wl = ws_->windowList();
3922
// iterate over all windows and determine which need an update
3923
std::vector<std::pair<const SpectrumWidget *, Size> > needs_update;
3924
for(int i=0; i!=ws_->windowList().count(); ++i)
3926
//std::cout << "Number of windows: " << ws_->windowList().count() << std::endl;
3928
const SpectrumWidget* sw = qobject_cast<const SpectrumWidget*>(w);
3931
Size lc = sw->canvas()->getLayerCount();
3933
// determine if widget stores one or more layers for the given filename (->needs update)
3934
for (Size j=0; j!= lc; ++j)
3936
//std::cout << "Layer filename: " << sw->canvas()->getLayer(j).filename << std::endl;
3937
const LayerData& ld = sw->canvas()->getLayer(j);
3938
if (ld.filename == filename)
3940
needs_update.push_back(std::pair<const SpectrumWidget *, Size>(sw,j));
3946
if (needs_update.empty()) // no layer references data of filename
3948
watcher_->removeFile(filename); // remove watcher
3950
} else if ( !needs_update.empty() ) // at least one layer references data of filename
3952
//std::cout << "Number of Layers that need update: " << needs_update.size() << std::endl;
3953
pair<const SpectrumWidget *, Size>& slp = needs_update[0];
3954
const SpectrumWidget * sw = slp.first;
3955
Size layer_index = slp.second;
3957
bool user_wants_update = false;
3958
if ((String)(param_.getValue("preferences:on_file_change"))=="update automatically") //automatically update
3960
user_wants_update = true;
3962
else if ((String)(param_.getValue("preferences:on_file_change"))=="ask") //ask the user if the layer should be updated
3964
if (watcher_msgbox_==true)
3965
{ // we already have a dialog for that opened... do not ask again
3968
// track that we will show the msgbox and we do not need to show it again if file changes once more and the dialog is still open
3969
watcher_msgbox_=true;
3970
QMessageBox msg_box;
3971
QAbstractButton* ok = msg_box.addButton(QMessageBox::Ok);
3972
msg_box.addButton(QMessageBox::Cancel);
3973
msg_box.setWindowTitle("Layer data changed");
3974
msg_box.setText((String("The data of file '") + filename + "' has changed.<BR>Update layers?").toQString());
3976
watcher_msgbox_=false;
3977
if (msg_box.clickedButton() == ok)
3979
user_wants_update = true;
3983
if (user_wants_update == false)
3987
else //if (user_wants_update == true)
3989
const LayerData& layer = sw->canvas()->getLayer(layer_index);
3991
if (layer.type==LayerData::DT_PEAK) //peak data
3995
FileHandler().loadExperiment(layer.filename,*layer.getPeakData());
3997
catch(Exception::BaseException& e)
3999
QMessageBox::critical(this,"Error",(String("Error while loading file") + layer.filename + "\nError message: " + e.what()).toQString());
4000
layer.getPeakData()->clear(true);
4002
layer.getPeakData()->sortSpectra(true);
4003
layer.getPeakData()->updateRanges(1);
4005
else if (layer.type==LayerData::DT_FEATURE) //feature data
4009
FileHandler().loadFeatures(layer.filename,*layer.getFeatureMap());
4011
catch(Exception::BaseException& e)
4013
QMessageBox::critical(this,"Error",(String("Error while loading file") + layer.filename + "\nError message: " + e.what()).toQString());
4014
layer.getFeatureMap()->clear(true);
4016
layer.getFeatureMap()->updateRanges();
4018
else if (layer.type==LayerData::DT_CONSENSUS) //consensus feature data
4022
ConsensusXMLFile().load(layer.filename,*layer.getConsensusMap());
4024
catch(Exception::BaseException& e)
4026
QMessageBox::critical(this,"Error",(String("Error while loading file") + layer.filename + "\nError message: " + e.what()).toQString());
4027
layer.getConsensusMap()->clear(true);
4029
layer.getConsensusMap()->updateRanges();
4031
else if (layer.type==LayerData::DT_CHROMATOGRAM) //chromatgram
4036
FileHandler().loadExperiment(layer.filename,*layer.getPeakData());
4038
catch(Exception::BaseException& e)
4040
QMessageBox::critical(this,"Error",(String("Error while loading file") + layer.filename + "\nError message: " + e.what()).toQString());
4041
layer.getPeakData()->clear(true);
4043
layer.getPeakData()->sortChromatograms(true);
4044
layer.getPeakData()->updateRanges(1);
4047
/* else if (layer.type == LayerData::DT_IDENT) // identifications
4051
vector<ProteinIdentification> proteins;
4052
IdXMLFile().load(layer.filename, proteins, layer.peptides);
4054
catch(Exception::BaseException& e)
4056
QMessageBox::critical(this,"Error",(String("Error while loading file") + layer.filename + "\nError message: " + e.what()).toQString());
4057
layer.peptides.clear();
4063
// update all layers that need an update
4064
for (Size i=0; i!= needs_update.size(); ++i)
4066
pair<const SpectrumWidget *, Size>& slp = needs_update[i];
4067
const SpectrumWidget * sw = slp.first;
4068
Size layer_index = slp.second;
4069
sw->canvas()->updateLayer(layer_index);
4074
//update the layer if the user choosed to do so
4077
emit sendStatusMessage(String("Updating layer '") + getLayer(j).name + "' (file changed).",0);
4079
emit sendStatusMessage(String("Finished updating layer '") + getLayer(j).name + "'.",5000);
4088
// temporarily remove and read filename from watcher_ as a workaround for bug #233
4089
watcher_->removeFile(filename);
4090
watcher_->addFile(filename);
4093
void TOPPViewBase::setTOPPASTabEnabled(bool enabled)
4095
if (views_tabwidget_->isTabEnabled(2) != enabled)
4097
views_tabwidget_->setTabEnabled(2, enabled);
4101
// ******************************************TOPPAS events**********************************
4102
void TOPPViewBase::newPipeline()
4104
TOPPASWidget* tw = new TOPPASWidget(Param(), ws_, toppas_tmp_path_);
4105
TOPPASScene* ts = tw->getScene();
4106
connect (ts, SIGNAL(selectionCopied(TOPPASScene*)), this, SLOT(saveToClipboard(TOPPASScene*)));
4107
connect (ts, SIGNAL(requestClipboardContent()), this, SLOT(sendClipboardContent()));
4108
connect (ts, SIGNAL(saveMe()), this, SLOT(savePipeline()));
4109
connect (ts, SIGNAL(mainWindowNeedsUpdate()), this, SLOT(updateMenu()));
4110
showTOPPipelineInWindow_(tw, "(Untitled)");
4113
void TOPPViewBase::includePipeline()
4115
QString file_name = QFileDialog::getOpenFileName(this, tr("Include workflow"), current_path_.toQString(), tr("TOPPAS pipelines (*.toppas)"));
4116
addTOPPASFile(file_name, false);
4119
void TOPPViewBase::savePipeline()
4121
TOPPASWidget* w = 0;
4122
QObject* sendr = QObject::sender();
4123
QAction* save_button_clicked = qobject_cast<QAction*>(sendr);
4125
if (!save_button_clicked)
4127
// scene has requested to be saved
4128
TOPPASScene* ts = qobject_cast<TOPPASScene*>(sendr);
4129
if (ts && ts->views().size() > 0)
4131
w = qobject_cast<TOPPASWidget*>(ts->views().first());
4136
w = getActiveTOPPASWidget();
4144
String file_name = w->getScene()->getSaveFileName();
4145
if (file_name != "")
4147
if (!file_name.hasSuffix(".toppas"))
4149
file_name += ".toppas";
4151
w->getScene()->store(file_name);
4155
TOPPASBase::savePipelineAs(w, current_path_.toQString());
4159
void TOPPViewBase::saveCurrentPipelineAs()
4161
TOPPASWidget* w = getActiveTOPPASWidget();
4162
QString file_name = TOPPASBase::savePipelineAs(w, current_path_.toQString());
4163
if (file_name != "")
4165
QString caption = File::basename(file_name).toQString();
4166
tab_bar_->setTabText(tab_bar_->currentIndex(), caption);
4170
void TOPPViewBase::loadPipelineResourceFile()
4172
TOPPASWidget* w = getActiveTOPPASWidget();
4173
TOPPASBase::loadPipelineResourceFile(w, current_path_.toQString());
4176
void TOPPViewBase::savePipelineResourceFile()
4178
TOPPASWidget* w = getActiveTOPPASWidget();
4179
TOPPASBase::savePipelineResourceFile(w, current_path_.toQString());
4182
void TOPPViewBase::refreshPipelineParameters()
4184
TOPPASWidget* w = getActiveTOPPASWidget();
4185
QString file_name = TOPPASBase::refreshPipelineParameters(w, current_path_.toQString());
4186
if (file_name != "")
4188
QString caption = File::basename(file_name).toQString();
4189
tab_bar_->setTabText(tab_bar_->currentIndex(), caption);
4193
void TOPPViewBase::runPipeline()
4195
TOPPASWidget* w = getActiveTOPPASWidget();
4198
w->getScene()->runPipeline();
4202
void TOPPViewBase::abortPipeline()
4204
TOPPASWidget* w = getActiveTOPPASWidget();
4207
w->getScene()->abortPipeline();
4212
void TOPPViewBase::showPipelineFinishedLogMessage()
4214
showLogMessage_(LS_NOTICE, "Entire pipeline execution finished!", "");
4217
void TOPPViewBase::saveToClipboard(TOPPASScene* scene)
4219
if (toppas_clipboard_scene_ != 0)
4221
delete toppas_clipboard_scene_;
4222
toppas_clipboard_scene_ = 0;
4224
toppas_clipboard_scene_ = scene;
4227
void TOPPViewBase::sendClipboardContent()
4229
TOPPASScene* sndr = qobject_cast<TOPPASScene*>(QObject::sender());
4232
sndr->setClipboard(toppas_clipboard_scene_);
4236
void TOPPViewBase::toolStarted()
4238
TOPPASToolVertex* tv = qobject_cast<TOPPASToolVertex*>(QObject::sender());
4241
String text = tv->getName();
4242
String type = tv->getType();
4245
text += " ("+type+")";
4247
text += " started. Processing ...";
4249
showLogMessage_(LS_NOTICE, text, "");
4254
void TOPPViewBase::toolFinished()
4256
TOPPASToolVertex* tv = qobject_cast<TOPPASToolVertex*>(QObject::sender());
4259
String text = tv->getName();
4260
String type = tv->getType();
4263
text += " ("+type+")";
4265
text += " finished!";
4267
showLogMessage_(LS_NOTICE, text, "");
4272
void TOPPViewBase::toolCrashed()
4274
TOPPASToolVertex* tv = qobject_cast<TOPPASToolVertex*>(QObject::sender());
4277
String text = tv->getName();
4278
String type = tv->getType();
4281
text += " ("+type+")";
4283
text += " crashed!";
4285
showLogMessage_(LS_ERROR, text, "");
4290
void TOPPViewBase::toolFailed()
4292
TOPPASToolVertex* tv = qobject_cast<TOPPASToolVertex*>(QObject::sender());
4295
String text = tv->getName();
4296
String type = tv->getType();
4299
text += " ("+type+")";
4303
showLogMessage_(LS_ERROR, text, "");
4308
void TOPPViewBase::outputVertexFinished(const String& file)
4310
String text = "Output file '" + file + "' written.";
4311
showLogMessage_(LS_NOTICE, text, "");
4314
void TOPPViewBase::updateTOPPOutputLog(const QString& out)
4316
QString text = out; // shortened version for now (if we reintroduce simultaneous tool execution,
4317
// we need to rethink this (probably only trigger this slot when tool 100% finished)
4319
//show log if there is output
4320
qobject_cast<QWidget*>(log_->parent())->show();
4326
void TOPPViewBase::openFilesInTOPPView(QStringList files)
4328
foreach(QString s, files)
4330
addDataFile(s, false, false, s);
4336
TOPPViewBase::~TOPPViewBase()
4342
if(identificationview_behavior_ != 0)
4344
delete(identificationview_behavior_);
4347
if(spectraview_behavior_ != 0)
4349
delete(spectraview_behavior_);
4353
} //namespace OpenMS