OpenMS
TOPPViewBase.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg$
6 // $Authors: Marc Sturm, Timo Sachsenberg $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
14 //OpenMS
27 
28 //STL
29 #include <map>
30 
31 //QT
32 #include <QtWidgets/QMainWindow>
33 #include <QtWidgets/QButtonGroup>
34 #include <QActionGroup>
35 #include <QtCore/QStringList>
36 #include <QtCore/QProcess>
37 #include <QElapsedTimer>
38 
39 class QAction;
40 class QComboBox;
41 class QLabel;
42 class QLineEdit;
43 class QListWidget;
44 class QListWidgetItem;
45 class QTreeWidget;
46 class QTreeWidgetItem;
47 class QDockWidget;
48 class QToolButton;
49 class QCloseEvent;
50 class QCheckBox;
51 class QSplashScreen;
52 class QToolButton;
53 
54 namespace OpenMS
55 {
56  class DataSelectionTabs;
57  class FileWatcher;
58  class LogWindow;
59  class LayerListView;
60  class MultiGradientSelector;
61  class Plot1DWidget;
62  class Plot2DWidget;
63  class Plot3DWidget;
64  class ToolsDialog;
65 
100  class OPENMS_GUI_DLLAPI TOPPViewBase :
101  public QMainWindow,
102  public DefaultParamHandler
103  {
104  Q_OBJECT
105 
106  friend class TestTOPPView;
107 
108 public:
110 
111  //Feature map type
113  //Feature map managed type
115 
116  //Consensus feature map type
118  //Consensus map managed type
120 
121  //Peak map type
123  //Main managed data type (experiment)
125  //Main on-disc managed data type (experiment)
130 
132  enum class TOOL_SCAN
133  {
138  SKIP_SCAN,
140  SCAN_IF_NEWER_VERSION,
142  FORCE_SCAN
143  };
144 
145  enum class VERBOSITY
146  {
147  DEFAULT,
148  VERBOSE
149  };
150 
152  explicit TOPPViewBase(TOOL_SCAN scan_mode = TOOL_SCAN::SCAN_IF_NEWER_VERSION, VERBOSITY verbosity = VERBOSITY::DEFAULT, QWidget* parent = nullptr);
154  ~TOPPViewBase() override;
155 
156  enum class LOAD_RESULT
157  {
158  OK,
159  FILE_NOT_FOUND,
160  FILETYPE_UNKNOWN,
161  FILETYPE_UNSUPPORTED,
162  LOAD_ERROR
163  };
164 
177  LOAD_RESULT addDataFile(const String& filename, bool show_options, bool add_to_recent, String caption = "", UInt window_id = 0, Size spectrum_id = 0);
178 
196  void addData(const FeatureMapSharedPtrType& feature_map,
197  const ConsensusMapSharedPtrType& consensus_map,
198  std::vector<PeptideIdentification>& peptides,
199  const ExperimentSharedPtrType& peak_map,
200  const ODExperimentSharedPtrType& on_disc_peak_map,
201  LayerDataBase::DataType data_type,
202  bool show_as_1d,
203  bool show_options,
204  bool as_new_window = true,
205  const String& filename = "",
206  const String& caption = "",
207  UInt window_id = 0,
208  Size spectrum_id = 0);
209 
211  void loadFiles(const StringList& list, QSplashScreen* splash_screen);
212 
218  void loadPreferences(String filename = "");
219 
221  void savePreferences();
222 
224  Param getCanvasParameters(UInt dim) const;
225 
227  const LayerDataBase* getCurrentLayer() const;
228 
230  LayerDataBase* getCurrentLayer();
231 
232  //@name Accessors for the main gui components.
233  //@brief The top level enhanced workspace and the EnhancedTabWidgets resing in the EnhancedTabBar.
235  EnhancedWorkspace* getWorkspace();
237 
239  PlotWidget* getActivePlotWidget() const;
240 
242  Plot1DWidget* getActive1DWidget() const;
243 
245  Plot2DWidget* getActive2DWidget() const;
246 
248  Plot3DWidget* getActive3DWidget() const;
250 
252  PlotCanvas* getActiveCanvas() const;
253 
255  void showPlotWidgetInWindow(PlotWidget* sw);
256 
257 public slots:
259  void updateCurrentPath();
261  void openFilesByDialog(const String& initial_directory = "");
263  void showGoToDialog() const;
265  void preferencesDialog();
267  void layerStatistics() const;
269  void editMetadata();
271  void layerActivated();
273  void zoomOtherWindows() const;
275  void linkZoom();
277  void layerDeactivated();
279  void closeTab();
280 
282  void rerunTOPPTool();
283 
285  void updateBarsAndMenus();
287  void updateToolBar();
289  void updateLayerBar();
291  void updateViewBar();
293  void updateMenu();
295  void updateFilterBar();
302  void showStatusMessage(const std::string& msg, OpenMS::UInt time);
304  void showCursorStatus(const String& x, const String& y);
306  void showTOPPDialog();
308  void annotateWithAMS();
310  void annotateWithID();
312  void annotateWithOSW();
314  void showSpectrumGenerationDialog();
316  void showSpectrumAlignmentDialog();
318  void showCurrentPeaksAs2D();
320  void showCurrentPeaksAs3D();
322  void showCurrentPeaksAsIonMobility(const MSSpectrum& spec);
324  void showCurrentPeaksAsDIA(const Precursor& pc, const MSExperiment& exp);
326  void saveLayerAll() const;
328  void saveLayerVisible() const;
330  void toggleGridLines() const;
332  void toggleAxisLegends() const;
334  void toggleInterestingMZs() const;
336  void showPreferences() const;
338  void metadataFileDialog();
339 
343  void setDrawMode1D(int) const;
344  void setIntensityMode(int);
345  void changeLayerFlag(bool);
346  void changeLabel(QAction*);
347  void changeUnassigned(QAction*);
348  void resetZoom() const;
349  void toggleProjections();
351 
354  void openFile(const String& filename);
355 
357  void layerFilterVisibilityChange(bool) const;
358 
360  void showSpectrumMetaData(int spectrum_index) const;
361 
362 protected slots:
364  void finishTOPPToolExecution(int exitCode, QProcess::ExitStatus exitStatus);
366  void abortTOPPTool();
368  void showSpectrumBrowser();
369 
374  void closeByTab(int id);
376  void showWindow(int id);
378  void copyLayer(const QMimeData* data, QWidget* source, int id = -1);
380 
382  void updateProcessLog();
383 
385  void fileChanged_(const String&);
386 protected:
388  void initializeDefaultParameters_();
389 
393  QStringList chooseFilesDialog_(const String& path_overwrite = "");
394 
396 
397  QDockWidget* layer_dock_widget_;
398  QDockWidget* views_dockwidget_;
399  QDockWidget* filter_dock_widget_;
401 
404 
406 
408 
411 
413  FileWatcher* watcher_ = nullptr;
414 
416  bool watcher_msgbox_ = false;
417 
419  bool zoom_together_ = false;
420 
423 
428 
431 
435  QToolBar* tool_bar_;
436 
437  // common intensity modes
438  QButtonGroup* intensity_button_group_;
439 
440  // 1D specific stuff
441  QToolBar* tool_bar_1d_;
442  QButtonGroup* draw_group_1d_;
443 
444  // 2D specific stuff
445  QToolBar* tool_bar_2d_peak_;
446  QToolBar* tool_bar_2d_feat_;
447  QToolBar* tool_bar_2d_cons_;
450  QAction* dm_hull_2d_;
451  QAction* dm_hulls_2d_;
452  QToolButton* dm_label_2d_;
453  QActionGroup* group_label_2d_;
454  QToolButton* dm_unassigned_2d_;
455  QActionGroup* group_unassigned_2d_;
456  QAction* dm_elements_2d_;
457  QAction* projections_2d_;
458  QAction* dm_ident_2d_;
460 
462  EnhancedWorkspace ws_; // not a pointer, but an actual object, so it gets destroyed before the DefaultParamhandler (on which it depends)
466  QMdiSubWindow* lastActiveSubwindow_ = nullptr; // due to Qt bugs or confusing features we need to save the current Window id in the children of the workspace;
470  RecentFilesMenu recent_files_; // needs to be declared before 'menu_', because its needed there
473 
478  QLabel* message_label_;
480  QLabel* x_label_;
482  QLabel* y_label_;
484 
486 
487  void addRecentFile_(const String& filename);
489 
491 
492 
494 
495  void runTOPPTool_();
498  struct
499  {
500  Param param;
501  String tool;
502  String in;
503  String out;
504  String file_name;
505  String file_name_in;
506  String file_name_out;
507  String layer_name;
508  UInt window_id;
509  Size spectrum_id;
510  QProcess* process = nullptr;
511  QElapsedTimer timer;
512  bool visible_area_only;
513  } topp_;
515 
519 
520  void closeEvent(QCloseEvent* event) override;
522 
525 
527  void showTOPPDialog_(bool visible);
528 
532 
533 private:
536 
539  }; //class
540 
541 } //namespace
542 
A container for consensus elements.
Definition: ConsensusMap.h:66
A tabbed view, to browse lists of spectra or identifications.
Definition: DataSelectionTabs.h:51
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Convenience tab bar implementation.
Definition: EnhancedTabBar.h:36
Definition: EnhancedWorkspace.h:27
A container for features.
Definition: FeatureMap.h:80
Watcher that monitors file changes.
Definition: FileWatcher.h:41
A widget which shows a list of DataFilter items.
Definition: FilterList.h:35
Class that stores the data for one layer.
Definition: LayerDataBase.h:169
Pimped QListView for Layers of a Canvas.
Definition: LayerListView.h:28
A log window (QTextEdit) with convenience functions.
Definition: LogWindow.h:29
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
Management and storage of parameters / INI files.
Definition: Param.h:44
Widget for visualization of several spectra.
Definition: Plot1DWidget.h:41
Widget for 2D-visualization of peak map and feature map data.
Definition: Plot2DWidget.h:39
Widget for 3D-visualization of map data.
Definition: Plot3DWidget.h:29
Base class for visualization canvas classes.
Definition: PlotCanvas.h:120
Base class for spectrum widgets.
Definition: PlotWidget.h:57
Precursor meta information.
Definition: Precursor.h:35
Manages recent files opened by the user and provides a QMenu to go with it.
Definition: RecentFilesMenu.h:35
A more convenient string class.
Definition: String.h:34
Main window of TOPPView tool.
Definition: TOPPViewBase.h:103
QDockWidget * filter_dock_widget_
Definition: TOPPViewBase.h:399
QLabel * y_label_
y-axis label for messages in the status bar
Definition: TOPPViewBase.h:482
TheoreticalSpectrumGenerationDialog spec_gen_dialog_
This dialog is a member so that its settings can be perserved upon closing.
Definition: TOPPViewBase.h:538
QDockWidget * views_dockwidget_
Definition: TOPPViewBase.h:398
LayerDataBase::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Definition: TOPPViewBase.h:119
TOPPViewMenu menu_
manages the menu items (active/inactive) and recent files etc
Definition: TOPPViewBase.h:472
VERBOSITY verbosity_
Verbosity of TV.
Definition: TOPPViewBase.h:430
TOOL_SCAN
Used for deciding whether new tool/util params should be generated or reused from TOPPView's ini file...
Definition: TOPPViewBase.h:133
LayerDataBase::FeatureMapSharedPtrType FeatureMapSharedPtrType
Definition: TOPPViewBase.h:114
QToolButton * dm_label_2d_
Definition: TOPPViewBase.h:452
QButtonGroup * draw_group_1d_
Definition: TOPPViewBase.h:442
ExperimentType::SpectrumType SpectrumType
Peak spectrum type.
Definition: TOPPViewBase.h:128
QToolBar * tool_bar_2d_feat_
Definition: TOPPViewBase.h:446
static const String CAPTION_3D_SUFFIX_
Suffix appended to caption of tabs when layer is shown in 3D.
Definition: TOPPViewBase.h:535
EnhancedTabBar tab_bar_
Tab bar. The address of the corresponding window to a tab is stored as an int in tabData()
Definition: TOPPViewBase.h:468
QActionGroup * group_label_2d_
Definition: TOPPViewBase.h:453
TVToolDiscovery tool_scanner_
Scans for tools and generates a param for each.
Definition: TOPPViewBase.h:427
FilterList * filter_list_
Definition: TOPPViewBase.h:409
QAction * dm_precursors_2d_
Definition: TOPPViewBase.h:449
void checkPreferences_()
check if all available preferences get set by the .ini file. If there are some missing entries fill t...
QButtonGroup * intensity_button_group_
Definition: TOPPViewBase.h:438
QActionGroup * group_unassigned_2d_
Definition: TOPPViewBase.h:455
QAction * dm_hull_2d_
Definition: TOPPViewBase.h:450
DataSelectionTabs * selection_view_
Definition: TOPPViewBase.h:405
QAction * dm_ident_2d_
Definition: TOPPViewBase.h:458
LayerDataBase::FeatureMapType FeatureMapType
Definition: TOPPViewBase.h:112
QAction * dm_hulls_2d_
Definition: TOPPViewBase.h:451
EnhancedWorkspace ws_
Main workspace.
Definition: TOPPViewBase.h:462
QToolBar * tool_bar_2d_peak_
Definition: TOPPViewBase.h:445
QAction * dm_elements_2d_
Definition: TOPPViewBase.h:456
TOOL_SCAN scan_mode_
Determines TVToolDiscovery scans for tools and generates new params.
Definition: TOPPViewBase.h:425
VERBOSITY
Definition: TOPPViewBase.h:146
RecentFilesMenu recent_files_
manages recent list of filenames and the menu that goes with it
Definition: TOPPViewBase.h:470
QAction * projections_2d_
Definition: TOPPViewBase.h:457
QLabel * message_label_
Label for messages in the status bar.
Definition: TOPPViewBase.h:478
QMenu * add_2d_context_
Additional context menu for 2D layers.
Definition: TOPPViewBase.h:524
LayerListView * layers_view_
Layer management widget.
Definition: TOPPViewBase.h:403
LOAD_RESULT
Definition: TOPPViewBase.h:157
QToolBar * tool_bar_
Definition: TOPPViewBase.h:435
QLabel * x_label_
x-axis label for messages in the status bar
Definition: TOPPViewBase.h:480
QToolBar * tool_bar_2d_cons_
Definition: TOPPViewBase.h:447
QToolButton * dm_unassigned_2d_
Definition: TOPPViewBase.h:454
String current_path_
Definition: TOPPViewBase.h:531
LayerDataBase::ConsensusMapType ConsensusMapType
Definition: TOPPViewBase.h:117
LayerDataBase::ExperimentSharedPtrType ExperimentSharedPtrType
Definition: TOPPViewBase.h:124
QToolBar * tool_bar_1d_
Definition: TOPPViewBase.h:441
QToolBar * tool_bar_2d_ident_
Definition: TOPPViewBase.h:448
LayerDataBase::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: TOPPViewBase.h:126
QDockWidget * layer_dock_widget_
Definition: TOPPViewBase.h:397
LogWindow * log_
Log output window.
Definition: TOPPViewBase.h:422
LayerDataBase::ExperimentType ExperimentType
Definition: TOPPViewBase.h:122
The file menu items for TOPPView.
Definition: TOPPViewMenu.h:58
Scans for tools and generates a param for each asynchronously.
Definition: TVToolDiscovery.h:37
Dialog which allows to enter an AA or NA sequence and generates a theoretical spectrum for it.
Definition: TheoreticalSpectrumGenerationDialog.h:49
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerDataBase.h:126
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerDataBase.h:131
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerDataBase.h:114
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerDataBase.h:120
DataType
Definition: LayerDataBase.h:73