OpenMS  2.4.0
TOPPViewBase.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2018.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg$
32 // $Authors: Marc Sturm, Timo Sachsenberg $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 //OpenMS
48 
51 
52 //STL
53 #include <map>
54 
55 //QT
56 #include <QtWidgets/QMainWindow>
57 #include <QtWidgets/QButtonGroup>
58 #include <QtWidgets/QActionGroup>
59 #include <QtCore/QStringList>
60 #include <QtCore/QProcess>
61 
62 class QAction;
63 class QComboBox;
64 class QLabel;
65 class QLineEdit;
66 class QListWidget;
67 class QListWidgetItem;
68 class QTreeWidget;
69 class QTreeWidgetItem;
70 class QDockWidget;
71 class QToolButton;
72 class QCloseEvent;
73 class QTextEdit;
74 class QCheckBox;
75 class QSplashScreen;
76 class QToolButton;
77 class QWorkspace;
78 
79 namespace OpenMS
80 {
81  class EnhancedWorkspace;
82  class EnhancedTabBar;
83  class Spectrum1DWidget;
84  class Spectrum2DWidget;
85  class Spectrum3DWidget;
86  class ToolsDialog;
87  class MultiGradientSelector;
88  class FileWatcher;
89 
124  class OPENMS_GUI_DLLAPI TOPPViewBase :
125  public QMainWindow,
126  public DefaultParamHandler
127  {
128  Q_OBJECT
129 
130  friend class TestTOPPView;
131 
132 public:
134 
135  //Feature map type
137  //Feature map managed type
139 
140  //Consensus feature map type
142  //Consensus map managed type
144 
145  //Peak map type
147  //Main managed data type (experiment)
149  //Main on-disc managed data type (experiment)
154 
156  TOPPViewBase(QWidget* parent = nullptr);
158  ~TOPPViewBase() override;
159 
172  void addDataFile(const String& filename, bool show_options, bool add_to_recent, String caption = "", UInt window_id = 0, Size spectrum_id = 0);
173 
190  void addData(FeatureMapSharedPtrType feature_map,
191  ConsensusMapSharedPtrType consensus_map,
192  std::vector<PeptideIdentification>& peptides,
193  ExperimentSharedPtrType peak_map,
194  ODExperimentSharedPtrType on_disc_peak_map,
195  LayerData::DataType data_type,
196  bool show_as_1d,
197  bool show_options,
198  bool as_new_window = true,
199  const String& filename = "",
200  const String& caption = "",
201  UInt window_id = 0,
202  Size spectrum_id = 0);
203 
205  void loadFiles(const StringList& list, QSplashScreen* splash_screen);
206 
212  void loadPreferences(String filename = "");
213 
215  void savePreferences();
216 
218  Param getSpectrumParameters(UInt dim);
219 
221  const LayerData* getCurrentLayer() const;
222 
223  //@name Accessors for the main gui components.
224  //@brief The top level enhanced workspace and the EnhancedTabWidgets resing in the EnhancedTabBar.
226  EnhancedWorkspace* getWorkspace() const;
228 
230  SpectrumWidget* getActiveSpectrumWidget() const;
231 
233  Spectrum1DWidget* getActive1DWidget() const;
234 
236  Spectrum2DWidget* getActive2DWidget() const;
237 
239  Spectrum3DWidget* getActive3DWidget() const;
241 
243  SpectrumCanvas* getActiveCanvas() const;
244 
245 
247  SpectraIdentificationViewWidget* getSpectraIdentificationViewWidget();
248 
250  void showSpectrumWidgetInWindow(SpectrumWidget* sw, const String& caption);
251 
252 public slots:
254  void updateCurrentPath();
256  void showURL();
258  void openFileDialog();
260  void openExampleDialog();
262  void showGoToDialog();
264  void preferencesDialog();
266  void layerStatistics();
268  void editMetadata();
270  void layerActivated();
272  void layerZoomChanged();
274  void linkZoom();
276  void layerDeactivated();
278  void closeFile();
280  void updateToolBar();
282  void updateLayerBar();
284  void updateViewBar();
286  void viewChanged(int);
288  void viewTabwidgetDoubleClicked(int);
290  void updateFilterBar();
292  void updateMenu();
294  void updateTabBar(QMdiSubWindow* w);
296  void tileVertical();
298  void tileHorizontal();
305  void showStatusMessage(std::string msg, OpenMS::UInt time);
307  void showCursorStatus(double mz, double rt);
309  void showCursorStatusInvert(double mz, double rt);
311  void showTOPPDialog();
313  void annotateWithID();
315  void showSpectrumGenerationDialog();
317  void showSpectrumAlignmentDialog();
319  void showSpectrumAs1D(int index);
320  void showSpectrumAs1D(std::vector<int, std::allocator<int> > indices);
322  void showCurrentPeaksAs2D();
324  void showCurrentPeaksAs3D();
326  void showCurrentPeaksAsIonMobility();
328  void showCurrentPeaksAsDIA();
330  void showAboutDialog();
332  void saveLayerAll();
334  void saveLayerVisible();
336  void toggleGridLines();
338  void toggleAxisLegends();
340  void showPreferences();
342  void metadataFileDialog();
343 
347  void setDrawMode1D(int);
348  void setIntensityMode(int);
349  void changeLayerFlag(bool);
350  void changeLabel(QAction*);
351  void changeUnassigned(QAction*);
352  void resetZoom();
353  void toggleProjections();
355 
357  void loadFile(QString);
358 
359 protected slots:
363  void layerSelectionChange(int);
366  void layerFilterVisibilityChange(bool);
368  void layerContextMenu(const QPoint& pos);
370  void logContextMenu(const QPoint& pos);
372  void layerVisibilityChange(QListWidgetItem* item);
374  void filterContextMenu(const QPoint& pos);
376  void filterEdit(QListWidgetItem* item);
378  void layerEdit(QListWidgetItem* /*item*/);
380 
382  void finishTOPPToolExecution(int exitCode, QProcess::ExitStatus exitStatus);
384  void abortTOPPTool();
386  void rerunTOPPTool();
388  void showSpectrumBrowser();
390  void showSpectrumMetaData(int spectrum_index);
391 
395  void closeByTab(int id);
398  void enhancedWorkspaceWindowChanged(int id);
400  void openRecentFile();
402  void copyLayer(const QMimeData* data, QWidget* source, int id = -1);
404 
406  void updateProcessLog();
407 
409  void fileChanged_(const String&);
410 protected:
412  void initializeDefaultParameters_();
413 
416  bool annotateMS1FromMassFingerprinting_(const FeatureMap& identifications);
417 
419  std::set<String> getFilenamesOfOpenFiles_();
420 
424  QStringList getFileList_(const String& path_overwrite = "");
425 
427  EnhancedTabBarWidgetInterface* window_(int id) const;
428 
430 
431  QDockWidget* layer_dock_widget_;
432  QDockWidget* views_dockwidget_;
433  QDockWidget* filter_dock_widget_;
435 
437 
441 
444 
446 
448  QCheckBox* filters_check_box_;
450 
453 
456 
459 
461 
464 
468  QToolBar* tool_bar_;
469 
470  // common intensity modes
471  QButtonGroup* intensity_button_group_;
472 
473  // 1D specific stuff
474  QToolBar* tool_bar_1d_;
475  QButtonGroup* draw_group_1d_;
476 
477  // 2D specific stuff
478  QToolBar* tool_bar_2d_peak_;
479  QToolBar* tool_bar_2d_feat_;
480  QToolBar* tool_bar_2d_cons_;
483  QAction* dm_hull_2d_;
484  QAction* dm_hulls_2d_;
485  QToolButton* dm_label_2d_;
486  QActionGroup* group_label_2d_;
487  QToolButton* dm_unassigned_2d_;
488  QActionGroup* group_unassigned_2d_;
489  QAction* dm_elements_2d_;
490  QAction* projections_2d_;
491  QAction* dm_ident_2d_;
493 
496 
499 
503  QLabel* message_label_;
506  QLabel* mz_label_;
508  QLabel* rt_label_;
510 
512 
513  void addRecentFile_(const String& filename);
516  void updateRecentMenu_();
518  QStringList recent_files_;
520  std::vector<QAction*> recent_actions_;
522 
523 
525 
526  void runTOPPTool_();
529  struct
530  {
540  QTime timer;
541  bool visible;
542  } topp_;
544 
546  void checkPreferences_();
548 
549  void closeEvent(QCloseEvent* event) override;
551 
553  enum LogState
554  {
557  LS_ERROR
558  };
560  void showLogMessage_(LogState state, const String& heading, const String& body);
561 
564 
566  void showTOPPDialog_(bool visible);
567 
571 
573  QTabWidget* views_tabwidget_;
574 
579 
580  // static helper functions
581 public:
583  static bool containsMS1Scans(const ExperimentType& exp);
584 
586  static bool containsIMData(const MSSpectrum& s);
587 
589  float estimateNoiseFromRandomMS1Scans(const ExperimentType& exp, UInt n_scans = 10);
590 
592  static bool hasMS1Zeros(const ExperimentType& exp);
593 
595  static bool hasPeptideIdentifications(const ExperimentType& map);
596 
597 private:
600  }; //class
601 
602 } //namespace
603 
String layer_name
Definition: TOPPViewBase.h:536
LayerData::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Definition: TOPPViewBase.h:143
QLabel * rt_label_
RT label for messages in the status bar.
Definition: TOPPViewBase.h:508
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerData.h:135
TOPPViewIdentificationViewBehavior * identificationview_behavior_
TOPPView behavior for the identification view.
Definition: TOPPViewBase.h:576
QDockWidget * filter_dock_widget_
Definition: TOPPViewBase.h:433
QAction * linkZoom_action_
Definition: TOPPViewBase.h:460
QButtonGroup * draw_group_1d_
Definition: TOPPViewBase.h:475
QToolBar * tool_bar_1d_
Definition: TOPPViewBase.h:474
Behavior of TOPPView in identification mode.
Definition: TOPPViewIdentificationViewBehavior.h:49
std::vector< QAction * > recent_actions_
list of the recently opened files actions (menu entries)
Definition: TOPPViewBase.h:520
A more convenient string class.
Definition: String.h:57
QAction * dm_hulls_2d_
Definition: TOPPViewBase.h:484
QToolBar * tool_bar_2d_ident_
Definition: TOPPViewBase.h:481
LayerData::ExperimentSharedPtrType ExperimentSharedPtrType
Definition: TOPPViewBase.h:148
bool visible
Definition: TOPPViewBase.h:541
LayerData::ConsensusMapType ConsensusMapType
Definition: TOPPViewBase.h:141
QListWidget * filters_
Definition: TOPPViewBase.h:447
LayerData::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: TOPPViewBase.h:150
Hierarchical visualization and selection of spectra.
Definition: SpectraViewWidget.h:51
Main window of TOPPView tool.
Definition: TOPPViewBase.h:124
String tool
Definition: TOPPViewBase.h:532
String file_name
Definition: TOPPViewBase.h:535
QToolBar * tool_bar_2d_feat_
Definition: TOPPViewBase.h:479
DataType
Dataset types.
Definition: LayerData.h:91
A container for features.
Definition: FeatureMap.h:93
Widget for 2D-visualization of peak map and feature map data.
Definition: Spectrum2DWidget.h:63
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
QToolBar * tool_bar_2d_cons_
Definition: TOPPViewBase.h:480
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:100
A container for consensus elements.
Definition: ConsensusMap.h:75
QToolBar * tool_bar_2d_peak_
Definition: TOPPViewBase.h:478
SpectraIdentificationViewWidget * spectra_identification_view_widget_
Definition: TOPPViewBase.h:439
QAction * dm_elements_2d_
Definition: TOPPViewBase.h:489
QAction * dm_hull_2d_
Definition: TOPPViewBase.h:483
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
FileWatcher * watcher_
Watcher that tracks file changes (in order to update the data in the different views) ...
Definition: TOPPViewBase.h:452
String in
Definition: TOPPViewBase.h:533
bool zoom_together_
Stores whether the individual windows should zoom together (be linked) or not.
Definition: TOPPViewBase.h:458
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerData.h:147
QTime timer
Definition: TOPPViewBase.h:540
QDockWidget * layer_dock_widget_
Definition: TOPPViewBase.h:431
bool watcher_msgbox_
Holds the messageboxes for each layer that are currently popped up (to avoid popping them up again...
Definition: TOPPViewBase.h:455
QAction * dm_ident_2d_
Definition: TOPPViewBase.h:491
Size spectrum_id
Definition: TOPPViewBase.h:538
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
SpectraViewWidget * spectra_view_widget_
Definition: TOPPViewBase.h:438
QLabel * mz_label_
m/z label for messages in the status bar
Definition: TOPPViewBase.h:506
TOPPViewSpectraViewBehavior * spectraview_behavior_
TOPPView behavior for the spectra view.
Definition: TOPPViewBase.h:578
LayerData::FeatureMapSharedPtrType FeatureMapSharedPtrType
Definition: TOPPViewBase.h:138
UInt window_id
Definition: TOPPViewBase.h:537
Param param
Definition: TOPPViewBase.h:531
QActionGroup * group_label_2d_
Definition: TOPPViewBase.h:486
Widget for visualization of several spectra.
Definition: Spectrum1DWidget.h:65
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerData.h:141
Base class for spectrum widgets.
Definition: SpectrumWidget.h:80
Warning.
Definition: TOPPViewBase.h:556
QTabWidget * views_tabwidget_
Tabwidget that hold the different views on the loaded data.
Definition: TOPPViewBase.h:573
static const String CAPTION_3D_SUFFIX_
Suffix appended to caption of tabs when layer is shown in 3D.
Definition: TOPPViewBase.h:599
Widget for 3D-visualization of map data.
Definition: Spectrum3DWidget.h:53
String out
Definition: TOPPViewBase.h:534
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
Management and storage of parameters / INI files.
Definition: Param.h:74
Behavior of TOPPView in spectra view mode.
Definition: TOPPViewSpectraViewBehavior.h:48
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
QButtonGroup * intensity_button_group_
Definition: TOPPViewBase.h:471
QToolButton * dm_unassigned_2d_
Definition: TOPPViewBase.h:487
QToolBar * tool_bar_
Definition: TOPPViewBase.h:468
Notice.
Definition: TOPPViewBase.h:555
QStringList recent_files_
list of the recently opened files
Definition: TOPPViewBase.h:518
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerData.h:152
Tabular visualization / selection of identified spectra.
Definition: SpectraIdentificationViewWidget.h:53
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Definition: EnhancedWorkspace.h:49
LogState
Log message states.
Definition: TOPPViewBase.h:553
QDockWidget * views_dockwidget_
Definition: TOPPViewBase.h:432
Widgets that are placed into an EnhancedTabBar must implement this interface.
Definition: EnhancedTabBarWidgetInterface.h:51
LayerData::FeatureMapType FeatureMapType
Definition: TOPPViewBase.h:136
QTextEdit * log_
Log output window.
Definition: TOPPViewBase.h:463
QListWidget * layer_manager_
Layer management widget.
Definition: TOPPViewBase.h:443
QActionGroup * group_unassigned_2d_
Definition: TOPPViewBase.h:488
EnhancedWorkspace * ws_
Main workspace.
Definition: TOPPViewBase.h:495
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
String current_path_
Definition: TOPPViewBase.h:570
EnhancedTabBar * tab_bar_
Tab bar. The address of the corresponding window to a tab is stored as an int in tabData() ...
Definition: TOPPViewBase.h:498
Watcher that monitors file changes.
Definition: FileWatcher.h:65
QCheckBox * filters_check_box_
Definition: TOPPViewBase.h:448
QMenu * add_2d_context_
Additional context menu for 2D layers.
Definition: TOPPViewBase.h:563
QToolButton * dm_label_2d_
Definition: TOPPViewBase.h:485
QAction * dm_precursors_2d_
Definition: TOPPViewBase.h:482
QProcess * process
Definition: TOPPViewBase.h:539
Class that stores the data for one layer.
Definition: LayerData.h:85
LayerData::ExperimentType ExperimentType
Definition: TOPPViewBase.h:146
Convenience tab bar implementation.
Definition: EnhancedTabBar.h:60
QAction * projections_2d_
Definition: TOPPViewBase.h:490
ExperimentType::SpectrumType SpectrumType
Peak spectrum type.
Definition: TOPPViewBase.h:152