OpenMS  2.5.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-2020.
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 
246  SpectraIdentificationViewWidget* getSpectraIdentificationViewWidget();
247 
249  void showSpectrumWidgetInWindow(SpectrumWidget* sw, const String& caption);
250 
251 public slots:
253  void updateCurrentPath();
255  void showURL();
257  void openFileDialog();
259  void openExampleDialog();
261  void showGoToDialog();
263  void preferencesDialog();
265  void layerStatistics();
267  void editMetadata();
269  void layerActivated();
271  void layerZoomChanged();
273  void linkZoom();
275  void layerDeactivated();
277  void closeFile();
279  void updateToolBar();
281  void updateLayerBar();
283  void updateViewBar();
285  void viewChanged(int);
287  void viewTabwidgetDoubleClicked(int);
289  void updateFilterBar();
291  void updateMenu();
293  void updateTabBar(QMdiSubWindow* w);
295  void tileVertical();
297  void tileHorizontal();
304  void showStatusMessage(std::string msg, OpenMS::UInt time);
306  void showCursorStatus(double mz, double rt);
308  void showCursorStatusInvert(double mz, double rt);
310  void showTOPPDialog();
312  void annotateWithID();
314  void showSpectrumGenerationDialog();
316  void showSpectrumAlignmentDialog();
318  void showSpectrumAs1D(int index);
319  void showSpectrumAs1D(std::vector<int, std::allocator<int> > indices);
321  void showCurrentPeaksAs2D();
323  void showCurrentPeaksAs3D();
325  void showCurrentPeaksAsIonMobility();
327  void showCurrentPeaksAsDIA();
329  void showAboutDialog();
331  void saveLayerAll();
333  void saveLayerVisible();
335  void toggleGridLines();
337  void toggleAxisLegends();
339  void toggleInterestingMZs();
341  void showPreferences();
343  void metadataFileDialog();
344 
348  void setDrawMode1D(int);
349  void setIntensityMode(int);
350  void changeLayerFlag(bool);
351  void changeLabel(QAction*);
352  void changeUnassigned(QAction*);
353  void resetZoom();
354  void toggleProjections();
356 
358  void loadFile(QString);
359 
360 protected slots:
364  void layerSelectionChange(int);
367  void layerFilterVisibilityChange(bool);
369  void layerContextMenu(const QPoint& pos);
371  void logContextMenu(const QPoint& pos);
373  void layerVisibilityChange(QListWidgetItem* item);
375  void filterContextMenu(const QPoint& pos);
377  void filterEdit(QListWidgetItem* item);
379  void layerEdit(QListWidgetItem* /*item*/);
381 
383  void finishTOPPToolExecution(int exitCode, QProcess::ExitStatus exitStatus);
385  void abortTOPPTool();
387  void rerunTOPPTool();
389  void showSpectrumBrowser();
391  void showSpectrumMetaData(int spectrum_index);
392 
396  void closeByTab(int id);
399  void enhancedWorkspaceWindowChanged(int id);
401  void openRecentFile();
403  void copyLayer(const QMimeData* data, QWidget* source, int id = -1);
405 
407  void updateProcessLog();
408 
410  void fileChanged_(const String&);
411 protected:
413  void initializeDefaultParameters_();
414 
417  bool annotateMS1FromMassFingerprinting_(const FeatureMap& identifications);
418 
420  std::set<String> getFilenamesOfOpenFiles_();
421 
425  QStringList getFileList_(const String& path_overwrite = "");
426 
428  EnhancedTabBarWidgetInterface* window_(int id) const;
429 
431 
432  QDockWidget* layer_dock_widget_;
433  QDockWidget* views_dockwidget_;
434  QDockWidget* filter_dock_widget_;
436 
438 
442 
445 
447 
449  QCheckBox* filters_check_box_;
451 
454 
457 
460 
462 
465 
469  QToolBar* tool_bar_;
470 
471  // common intensity modes
472  QButtonGroup* intensity_button_group_;
473 
474  // 1D specific stuff
475  QToolBar* tool_bar_1d_;
476  QButtonGroup* draw_group_1d_;
477 
478  // 2D specific stuff
479  QToolBar* tool_bar_2d_peak_;
480  QToolBar* tool_bar_2d_feat_;
481  QToolBar* tool_bar_2d_cons_;
484  QAction* dm_hull_2d_;
485  QAction* dm_hulls_2d_;
486  QToolButton* dm_label_2d_;
487  QActionGroup* group_label_2d_;
488  QToolButton* dm_unassigned_2d_;
489  QActionGroup* group_unassigned_2d_;
490  QAction* dm_elements_2d_;
491  QAction* projections_2d_;
492  QAction* dm_ident_2d_;
494 
497 
500 
504  QLabel* message_label_;
507  QLabel* mz_label_;
509  QLabel* rt_label_;
511 
513 
514  void addRecentFile_(const String& filename);
517  void updateRecentMenu_();
519  QStringList recent_files_;
521  std::vector<QAction*> recent_actions_;
523 
524 
526 
527  void runTOPPTool_();
530  struct
531  {
532  Param param;
533  String tool;
534  String in;
535  String out;
536  String file_name;
537  String layer_name;
538  UInt window_id;
539  Size spectrum_id;
540  QProcess* process;
541  QTime timer;
542  bool visible;
543  } topp_;
545 
547  void checkPreferences_();
549 
550  void closeEvent(QCloseEvent* event) override;
552 
554  enum LogState
555  {
558  LS_ERROR
559  };
561  void showLogMessage_(LogState state, const String& heading, const String& body);
562 
565 
567  void showTOPPDialog_(bool visible);
568 
572 
574  QTabWidget* views_tabwidget_;
575 
580 
581  // static helper functions
582 public:
584  static bool containsMS1Scans(const ExperimentType& exp);
585 
587  static bool containsIMData(const MSSpectrum& s);
588 
590  float estimateNoiseFromRandomMS1Scans(const ExperimentType& exp, UInt n_scans = 10);
591 
593  static bool hasMS1Zeros(const ExperimentType& exp);
594 
596  static bool hasPeptideIdentifications(const ExperimentType& map);
597 
598 private:
601  }; //class
602 
603 } //namespace
604 
QActionGroup * group_label_2d_
Definition: TOPPViewBase.h:487
Hierarchical visualization and selection of spectra.
Definition: SpectraViewWidget.h:51
bool watcher_msgbox_
Holds the messageboxes for each layer that are currently popped up (to avoid popping them up again...
Definition: TOPPViewBase.h:456
QAction * dm_elements_2d_
Definition: TOPPViewBase.h:490
QDockWidget * filter_dock_widget_
Definition: TOPPViewBase.h:434
EnhancedTabBar * tab_bar_
Tab bar. The address of the corresponding window to a tab is stored as an int in tabData() ...
Definition: TOPPViewBase.h:499
QToolButton * dm_unassigned_2d_
Definition: TOPPViewBase.h:488
String current_path_
Definition: TOPPViewBase.h:571
LogState
Log message states.
Definition: TOPPViewBase.h:554
QAction * dm_ident_2d_
Definition: TOPPViewBase.h:492
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerData.h:143
FileWatcher * watcher_
Watcher that tracks file changes (in order to update the data in the different views) ...
Definition: TOPPViewBase.h:453
Main window of TOPPView tool.
Definition: TOPPViewBase.h:124
Behavior of TOPPView in identification mode.
Definition: TOPPViewIdentificationViewBehavior.h:49
Widget for 2D-visualization of peak map and feature map data.
Definition: Spectrum2DWidget.h:63
QAction * dm_hulls_2d_
Definition: TOPPViewBase.h:485
SpectraIdentificationViewWidget * spectra_identification_view_widget_
Definition: TOPPViewBase.h:440
TOPPViewIdentificationViewBehavior * identificationview_behavior_
TOPPView behavior for the identification view.
Definition: TOPPViewBase.h:577
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
Watcher that monitors file changes.
Definition: FileWatcher.h:65
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Management and storage of parameters / INI files.
Definition: Param.h:73
Base class for spectrum widgets.
Definition: SpectrumWidget.h:80
Definition: EnhancedWorkspace.h:49
QButtonGroup * intensity_button_group_
Definition: TOPPViewBase.h:472
QAction * dm_precursors_2d_
Definition: TOPPViewBase.h:483
QToolBar * tool_bar_2d_feat_
Definition: TOPPViewBase.h:480
Notice.
Definition: TOPPViewBase.h:556
QToolBar * tool_bar_1d_
Definition: TOPPViewBase.h:475
DataType
Definition: LayerData.h:92
QToolBar * tool_bar_2d_ident_
Definition: TOPPViewBase.h:482
A container for features.
Definition: FeatureMap.h:95
QActionGroup * group_unassigned_2d_
Definition: TOPPViewBase.h:489
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerData.h:137
LayerData::ConsensusMapType ConsensusMapType
Definition: TOPPViewBase.h:141
QTabWidget * views_tabwidget_
Tabwidget that hold the different views on the loaded data.
Definition: TOPPViewBase.h:574
QCheckBox * filters_check_box_
Definition: TOPPViewBase.h:449
SpectraViewWidget * spectra_view_widget_
Definition: TOPPViewBase.h:439
LayerData::ExperimentType ExperimentType
Definition: TOPPViewBase.h:146
bool zoom_together_
Stores whether the individual windows should zoom together (be linked) or not.
Definition: TOPPViewBase.h:459
LayerData::FeatureMapSharedPtrType FeatureMapSharedPtrType
Definition: TOPPViewBase.h:138
QToolBar * tool_bar_2d_peak_
Definition: TOPPViewBase.h:479
LayerData::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: TOPPViewBase.h:150
QAction * dm_hull_2d_
Definition: TOPPViewBase.h:484
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
TOPPViewSpectraViewBehavior * spectraview_behavior_
TOPPView behavior for the spectra view.
Definition: TOPPViewBase.h:579
static const String CAPTION_3D_SUFFIX_
Suffix appended to caption of tabs when layer is shown in 3D.
Definition: TOPPViewBase.h:600
LayerData::ExperimentSharedPtrType ExperimentSharedPtrType
Definition: TOPPViewBase.h:148
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
QLabel * mz_label_
m/z label for messages in the status bar
Definition: TOPPViewBase.h:507
Tabular visualization / selection of identified spectra.
Definition: SpectraIdentificationViewWidget.h:53
ExperimentType::SpectrumType SpectrumType
Peak spectrum type.
Definition: TOPPViewBase.h:152
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:98
Widgets that are placed into an EnhancedTabBar must implement this interface.
Definition: EnhancedTabBarWidgetInterface.h:51
Behavior of TOPPView in spectra view mode.
Definition: TOPPViewSpectraViewBehavior.h:48
QToolButton * dm_label_2d_
Definition: TOPPViewBase.h:486
QToolBar * tool_bar_2d_cons_
Definition: TOPPViewBase.h:481
Widget for visualization of several spectra.
Definition: Spectrum1DWidget.h:65
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
QAction * linkZoom_action_
Definition: TOPPViewBase.h:461
QTextEdit * log_
Log output window.
Definition: TOPPViewBase.h:464
Widget for 3D-visualization of map data.
Definition: Spectrum3DWidget.h:53
Convenience tab bar implementation.
Definition: EnhancedTabBar.h:60
QButtonGroup * draw_group_1d_
Definition: TOPPViewBase.h:476
QAction * projections_2d_
Definition: TOPPViewBase.h:491
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerData.h:154
QToolBar * tool_bar_
Definition: TOPPViewBase.h:469
EnhancedWorkspace * ws_
Main workspace.
Definition: TOPPViewBase.h:496
A more convenient string class.
Definition: String.h:58
QStringList recent_files_
list of the recently opened files
Definition: TOPPViewBase.h:519
A container for consensus elements.
Definition: ConsensusMap.h:79
Class that stores the data for one layer.
Definition: LayerData.h:85
QDockWidget * views_dockwidget_
Definition: TOPPViewBase.h:433
LayerData::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Definition: TOPPViewBase.h:143
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerData.h:149
Warning.
Definition: TOPPViewBase.h:557
QListWidget * filters_
Definition: TOPPViewBase.h:448
QListWidget * layers_view_
Layer management widget.
Definition: TOPPViewBase.h:444
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
LayerData::FeatureMapType FeatureMapType
Definition: TOPPViewBase.h:136
QDockWidget * layer_dock_widget_
Definition: TOPPViewBase.h:432
QLabel * rt_label_
RT label for messages in the status bar.
Definition: TOPPViewBase.h:509
std::vector< QAction * > recent_actions_
list of the recently opened files actions (menu entries)
Definition: TOPPViewBase.h:521
QMenu * add_2d_context_
Additional context menu for 2D layers.
Definition: TOPPViewBase.h:564
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46