OpenMS
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-2023.
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
53 
54 //STL
55 #include <map>
56 
57 //QT
58 #include <QtWidgets/QMainWindow>
59 #include <QtWidgets/QButtonGroup>
60 #include <QtWidgets/QActionGroup>
61 #include <QtCore/QStringList>
62 #include <QtCore/QProcess>
63 #include <QElapsedTimer>
64 
65 class QAction;
66 class QComboBox;
67 class QLabel;
68 class QLineEdit;
69 class QListWidget;
70 class QListWidgetItem;
71 class QTreeWidget;
72 class QTreeWidgetItem;
73 class QDockWidget;
74 class QToolButton;
75 class QCloseEvent;
76 class QCheckBox;
77 class QSplashScreen;
78 class QToolButton;
79 
80 namespace OpenMS
81 {
82  class DataSelectionTabs;
83  class FileWatcher;
84  class LogWindow;
85  class LayerListView;
86  class MultiGradientSelector;
87  class Plot1DWidget;
88  class Plot2DWidget;
89  class Plot3DWidget;
90  class ToolsDialog;
91 
126  class OPENMS_GUI_DLLAPI TOPPViewBase :
127  public QMainWindow,
128  public DefaultParamHandler
129  {
130  Q_OBJECT
131 
132  friend class TestTOPPView;
133 
134 public:
136 
137  //Feature map type
139  //Feature map managed type
141 
142  //Consensus feature map type
144  //Consensus map managed type
146 
147  //Peak map type
149  //Main managed data type (experiment)
151  //Main on-disc managed data type (experiment)
156 
158  enum class TOOL_SCAN
159  {
164  SKIP_SCAN,
166  SCAN_IF_NEWER_VERSION,
168  FORCE_SCAN
169  };
170 
171  enum class VERBOSITY
172  {
173  DEFAULT,
174  VERBOSE
175  };
176 
178  explicit TOPPViewBase(TOOL_SCAN scan_mode = TOOL_SCAN::SCAN_IF_NEWER_VERSION, VERBOSITY verbosity = VERBOSITY::DEFAULT, QWidget* parent = nullptr);
180  ~TOPPViewBase() override;
181 
182  enum class LOAD_RESULT
183  {
184  OK,
185  FILE_NOT_FOUND,
186  FILETYPE_UNKNOWN,
187  FILETYPE_UNSUPPORTED,
188  LOAD_ERROR
189  };
190 
203  LOAD_RESULT addDataFile(const String& filename, bool show_options, bool add_to_recent, String caption = "", UInt window_id = 0, Size spectrum_id = 0);
204 
222  void addData(const FeatureMapSharedPtrType& feature_map,
223  const ConsensusMapSharedPtrType& consensus_map,
224  std::vector<PeptideIdentification>& peptides,
225  const ExperimentSharedPtrType& peak_map,
226  const ODExperimentSharedPtrType& on_disc_peak_map,
227  LayerDataBase::DataType data_type,
228  bool show_as_1d,
229  bool show_options,
230  bool as_new_window = true,
231  const String& filename = "",
232  const String& caption = "",
233  UInt window_id = 0,
234  Size spectrum_id = 0);
235 
237  void loadFiles(const StringList& list, QSplashScreen* splash_screen);
238 
244  void loadPreferences(String filename = "");
245 
247  void savePreferences();
248 
250  Param getCanvasParameters(UInt dim) const;
251 
253  const LayerDataBase* getCurrentLayer() const;
254 
256  LayerDataBase* getCurrentLayer();
257 
258  //@name Accessors for the main gui components.
259  //@brief The top level enhanced workspace and the EnhancedTabWidgets resing in the EnhancedTabBar.
261  EnhancedWorkspace* getWorkspace();
263 
265  PlotWidget* getActivePlotWidget() const;
266 
268  Plot1DWidget* getActive1DWidget() const;
269 
271  Plot2DWidget* getActive2DWidget() const;
272 
274  Plot3DWidget* getActive3DWidget() const;
276 
278  PlotCanvas* getActiveCanvas() const;
279 
281  void showPlotWidgetInWindow(PlotWidget* sw);
282 
283 public slots:
285  void updateCurrentPath();
287  void openFilesByDialog(const String& initial_directory = "");
289  void showGoToDialog() const;
291  void preferencesDialog();
293  void layerStatistics() const;
295  void editMetadata();
297  void layerActivated();
299  void zoomOtherWindows() const;
301  void linkZoom();
303  void layerDeactivated();
305  void closeTab();
306 
308  void rerunTOPPTool();
309 
311  void updateBarsAndMenus();
313  void updateToolBar();
315  void updateLayerBar();
317  void updateViewBar();
319  void updateMenu();
321  void updateFilterBar();
328  void showStatusMessage(const std::string& msg, OpenMS::UInt time);
330  void showCursorStatus(const String& x, const String& y);
332  void showTOPPDialog();
334  void annotateWithAMS();
336  void annotateWithID();
338  void annotateWithOSW();
340  void showSpectrumGenerationDialog();
342  void showSpectrumAlignmentDialog();
344  void showCurrentPeaksAs2D();
346  void showCurrentPeaksAs3D();
348  void showCurrentPeaksAsIonMobility(const MSSpectrum& spec);
350  void showCurrentPeaksAsDIA(const Precursor& pc, const MSExperiment& exp);
352  void saveLayerAll() const;
354  void saveLayerVisible() const;
356  void toggleGridLines() const;
358  void toggleAxisLegends() const;
360  void toggleInterestingMZs() const;
362  void showPreferences() const;
364  void metadataFileDialog();
365 
369  void setDrawMode1D(int) const;
370  void setIntensityMode(int);
371  void changeLayerFlag(bool);
372  void changeLabel(QAction*);
373  void changeUnassigned(QAction*);
374  void resetZoom() const;
375  void toggleProjections();
377 
380  void openFile(const String& filename);
381 
383  void layerFilterVisibilityChange(bool) const;
384 
386  void showSpectrumMetaData(int spectrum_index) const;
387 
388 protected slots:
390  void finishTOPPToolExecution(int exitCode, QProcess::ExitStatus exitStatus);
392  void abortTOPPTool();
394  void showSpectrumBrowser();
395 
400  void closeByTab(int id);
402  void showWindow(int id);
404  void copyLayer(const QMimeData* data, QWidget* source, int id = -1);
406 
408  void updateProcessLog();
409 
411  void fileChanged_(const String&);
412 protected:
414  void initializeDefaultParameters_();
415 
419  QStringList chooseFilesDialog_(const String& path_overwrite = "");
420 
422 
423  QDockWidget* layer_dock_widget_;
424  QDockWidget* views_dockwidget_;
425  QDockWidget* filter_dock_widget_;
427 
430 
432 
434 
437 
439  FileWatcher* watcher_ = nullptr;
440 
442  bool watcher_msgbox_ = false;
443 
445  bool zoom_together_ = false;
446 
449 
454 
457 
461  QToolBar* tool_bar_;
462 
463  // common intensity modes
464  QButtonGroup* intensity_button_group_;
465 
466  // 1D specific stuff
467  QToolBar* tool_bar_1d_;
468  QButtonGroup* draw_group_1d_;
469 
470  // 2D specific stuff
471  QToolBar* tool_bar_2d_peak_;
472  QToolBar* tool_bar_2d_feat_;
473  QToolBar* tool_bar_2d_cons_;
476  QAction* dm_hull_2d_;
477  QAction* dm_hulls_2d_;
478  QToolButton* dm_label_2d_;
479  QActionGroup* group_label_2d_;
480  QToolButton* dm_unassigned_2d_;
481  QActionGroup* group_unassigned_2d_;
482  QAction* dm_elements_2d_;
483  QAction* projections_2d_;
484  QAction* dm_ident_2d_;
486 
488  EnhancedWorkspace ws_; // not a pointer, but an actual object, so it gets destroyed before the DefaultParamhandler (on which it depends)
492  QMdiSubWindow* lastActiveSubwindow_ = nullptr; // due to Qt bugs or confusing features we need to save the current Window id in the children of the workspace;
496  RecentFilesMenu recent_files_; // needs to be declared before 'menu_', because its needed there
499 
504  QLabel* message_label_;
506  QLabel* x_label_;
508  QLabel* y_label_;
510 
512 
513  void addRecentFile_(const String& filename);
515 
517 
518 
520 
521  void runTOPPTool_();
524  struct
525  {
526  Param param;
527  String tool;
528  String in;
529  String out;
530  String file_name;
531  String layer_name;
532  UInt window_id;
533  Size spectrum_id;
534  QProcess* process = nullptr;
535  QElapsedTimer timer;
536  bool visible_area_only;
537  } topp_;
539 
543 
544  void closeEvent(QCloseEvent* event) override;
546 
549 
551  void showTOPPDialog_(bool visible);
552 
556 
557 private:
560 
563  }; //class
564 
565 } //namespace
566 
A container for consensus elements.
Definition: ConsensusMap.h:92
A tabbed view, to browse lists of spectra or identifications.
Definition: DataSelectionTabs.h:77
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
Convenience tab bar implementation.
Definition: EnhancedTabBar.h:62
Definition: EnhancedWorkspace.h:53
A container for features.
Definition: FeatureMap.h:106
Watcher that monitors file changes.
Definition: FileWatcher.h:67
A widget which shows a list of DataFilter items.
Definition: FilterList.h:61
Class that stores the data for one layer.
Definition: LayerDataBase.h:195
Pimped QListView for Layers of a Canvas.
Definition: LayerListView.h:54
A log window (QTextEdit) with convenience functions.
Definition: LogWindow.h:55
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
Management and storage of parameters / INI files.
Definition: Param.h:70
Widget for visualization of several spectra.
Definition: Plot1DWidget.h:67
Widget for 2D-visualization of peak map and feature map data.
Definition: Plot2DWidget.h:65
Widget for 3D-visualization of map data.
Definition: Plot3DWidget.h:55
Base class for visualization canvas classes.
Definition: PlotCanvas.h:146
Base class for spectrum widgets.
Definition: PlotWidget.h:83
Precursor meta information.
Definition: Precursor.h:61
Manages recent files opened by the user and provides a QMenu to go with it.
Definition: RecentFilesMenu.h:61
A more convenient string class.
Definition: String.h:60
Main window of TOPPView tool.
Definition: TOPPViewBase.h:129
QDockWidget * filter_dock_widget_
Definition: TOPPViewBase.h:425
QLabel * y_label_
y-axis label for messages in the status bar
Definition: TOPPViewBase.h:508
TheoreticalSpectrumGenerationDialog spec_gen_dialog_
This dialog is a member so that its settings can be perserved upon closing.
Definition: TOPPViewBase.h:562
QDockWidget * views_dockwidget_
Definition: TOPPViewBase.h:424
LayerDataBase::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Definition: TOPPViewBase.h:145
TOPPViewMenu menu_
manages the menu items (active/inactive) and recent files etc
Definition: TOPPViewBase.h:498
VERBOSITY verbosity_
Verbosity of TV.
Definition: TOPPViewBase.h:456
TOOL_SCAN
Used for deciding whether new tool/util params should be generated or reused from TOPPView's ini file...
Definition: TOPPViewBase.h:159
LayerDataBase::FeatureMapSharedPtrType FeatureMapSharedPtrType
Definition: TOPPViewBase.h:140
QToolButton * dm_label_2d_
Definition: TOPPViewBase.h:478
QButtonGroup * draw_group_1d_
Definition: TOPPViewBase.h:468
ExperimentType::SpectrumType SpectrumType
Peak spectrum type.
Definition: TOPPViewBase.h:154
QToolBar * tool_bar_2d_feat_
Definition: TOPPViewBase.h:472
static const String CAPTION_3D_SUFFIX_
Suffix appended to caption of tabs when layer is shown in 3D.
Definition: TOPPViewBase.h:559
EnhancedTabBar tab_bar_
Tab bar. The address of the corresponding window to a tab is stored as an int in tabData()
Definition: TOPPViewBase.h:494
QActionGroup * group_label_2d_
Definition: TOPPViewBase.h:479
TVToolDiscovery tool_scanner_
Scans for tools/utils and generates a param for each.
Definition: TOPPViewBase.h:453
FilterList * filter_list_
Definition: TOPPViewBase.h:435
QAction * dm_precursors_2d_
Definition: TOPPViewBase.h:475
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:464
QActionGroup * group_unassigned_2d_
Definition: TOPPViewBase.h:481
QAction * dm_hull_2d_
Definition: TOPPViewBase.h:476
DataSelectionTabs * selection_view_
Definition: TOPPViewBase.h:431
QAction * dm_ident_2d_
Definition: TOPPViewBase.h:484
LayerDataBase::FeatureMapType FeatureMapType
Definition: TOPPViewBase.h:138
QAction * dm_hulls_2d_
Definition: TOPPViewBase.h:477
EnhancedWorkspace ws_
Main workspace.
Definition: TOPPViewBase.h:488
QToolBar * tool_bar_2d_peak_
Definition: TOPPViewBase.h:471
QAction * dm_elements_2d_
Definition: TOPPViewBase.h:482
TOOL_SCAN scan_mode_
Determines TVToolDiscovery scans for tool/utils and generates new params.
Definition: TOPPViewBase.h:451
VERBOSITY
Definition: TOPPViewBase.h:172
RecentFilesMenu recent_files_
manages recent list of filenames and the menu that goes with it
Definition: TOPPViewBase.h:496
QAction * projections_2d_
Definition: TOPPViewBase.h:483
QLabel * message_label_
Label for messages in the status bar.
Definition: TOPPViewBase.h:504
QMenu * add_2d_context_
Additional context menu for 2D layers.
Definition: TOPPViewBase.h:548
LayerListView * layers_view_
Layer management widget.
Definition: TOPPViewBase.h:429
LOAD_RESULT
Definition: TOPPViewBase.h:183
QToolBar * tool_bar_
Definition: TOPPViewBase.h:461
QLabel * x_label_
x-axis label for messages in the status bar
Definition: TOPPViewBase.h:506
QToolBar * tool_bar_2d_cons_
Definition: TOPPViewBase.h:473
QToolButton * dm_unassigned_2d_
Definition: TOPPViewBase.h:480
String current_path_
Definition: TOPPViewBase.h:555
LayerDataBase::ConsensusMapType ConsensusMapType
Definition: TOPPViewBase.h:143
LayerDataBase::ExperimentSharedPtrType ExperimentSharedPtrType
Definition: TOPPViewBase.h:150
QToolBar * tool_bar_1d_
Definition: TOPPViewBase.h:467
QToolBar * tool_bar_2d_ident_
Definition: TOPPViewBase.h:474
LayerDataBase::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: TOPPViewBase.h:152
QDockWidget * layer_dock_widget_
Definition: TOPPViewBase.h:423
LogWindow * log_
Log output window.
Definition: TOPPViewBase.h:448
LayerDataBase::ExperimentType ExperimentType
Definition: TOPPViewBase.h:148
The file menu items for TOPPView.
Definition: TOPPViewMenu.h:84
Scans for tools/utils and generates a param for each asynchronously.
Definition: TVToolDiscovery.h:63
Dialog which allows to enter an AA or NA sequence and generates a theoretical spectrum for it.
Definition: TheoreticalSpectrumGenerationDialog.h:75
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerDataBase.h:152
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerDataBase.h:157
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerDataBase.h:140
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerDataBase.h:146
DataType
Definition: LayerDataBase.h:99