OpenMS  2.7.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-2021.
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
52 
53 //STL
54 #include <map>
55 
56 //QT
57 #include <QtWidgets/QMainWindow>
58 #include <QtWidgets/QButtonGroup>
59 #include <QtWidgets/QActionGroup>
60 #include <QtCore/QStringList>
61 #include <QtCore/QProcess>
62 
63 class QAction;
64 class QComboBox;
65 class QLabel;
66 class QLineEdit;
67 class QListWidget;
68 class QListWidgetItem;
69 class QTreeWidget;
70 class QTreeWidgetItem;
71 class QDockWidget;
72 class QToolButton;
73 class QCloseEvent;
74 class QCheckBox;
75 class QSplashScreen;
76 class QToolButton;
77 
78 namespace OpenMS
79 {
80  class DataSelectionTabs;
81  class FileWatcher;
82  class LogWindow;
83  class LayerListView;
84  class MultiGradientSelector;
85  class Plot1DWidget;
86  class Plot2DWidget;
87  class Plot3DWidget;
88  class ToolsDialog;
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  enum class TOOL_SCAN
157  {
162  SKIP_SCAN,
164  SCAN_IF_NEWER_VERSION,
166  FORCE_SCAN
167  };
168 
170  explicit TOPPViewBase(TOOL_SCAN scan_mode = TOOL_SCAN::SCAN_IF_NEWER_VERSION, QWidget* parent = nullptr);
172  ~TOPPViewBase() override;
173 
174  enum class LOAD_RESULT
175  {
176  OK,
177  FILE_NOT_FOUND,
178  FILETYPE_UNKNOWN,
179  FILETYPE_UNSUPPORTED,
180  LOAD_ERROR
181  };
182 
195  LOAD_RESULT addDataFile(const String& filename, bool show_options, bool add_to_recent, String caption = "", UInt window_id = 0, Size spectrum_id = 0);
196 
213  void addData(FeatureMapSharedPtrType feature_map,
214  ConsensusMapSharedPtrType consensus_map,
215  std::vector<PeptideIdentification>& peptides,
216  ExperimentSharedPtrType peak_map,
217  ODExperimentSharedPtrType on_disc_peak_map,
218  LayerData::DataType data_type,
219  bool show_as_1d,
220  bool show_options,
221  bool as_new_window = true,
222  const String& filename = "",
223  const String& caption = "",
224  UInt window_id = 0,
225  Size spectrum_id = 0);
226 
228  void loadFiles(const StringList& list, QSplashScreen* splash_screen);
229 
235  void loadPreferences(String filename = "");
236 
238  void savePreferences();
239 
241  Param getSpectrumParameters(UInt dim);
242 
244  const LayerData* getCurrentLayer() const;
245 
247  LayerData* getCurrentLayer();
248 
249  //@name Accessors for the main gui components.
250  //@brief The top level enhanced workspace and the EnhancedTabWidgets resing in the EnhancedTabBar.
252  EnhancedWorkspace* getWorkspace();
254 
256  PlotWidget* getActivePlotWidget() const;
257 
259  Plot1DWidget* getActive1DWidget() const;
260 
262  Plot2DWidget* getActive2DWidget() const;
263 
265  Plot3DWidget* getActive3DWidget() const;
267 
269  PlotCanvas* getActiveCanvas() const;
270 
272  void showPlotWidgetInWindow(PlotWidget* sw, const String& caption);
273 
274 public slots:
276  void updateCurrentPath();
278  void openFilesByDialog(const String& initial_directory = "");
280  void showGoToDialog();
282  void preferencesDialog();
284  void layerStatistics();
286  void editMetadata();
288  void layerActivated();
290  void layerZoomChanged();
292  void linkZoom();
294  void layerDeactivated();
296  void closeTab();
297 
299  void rerunTOPPTool();
300 
302  void updateBarsAndMenus();
304  void updateToolBar();
306  void updateLayerBar();
308  void updateViewBar();
310  void updateMenu();
312  void updateFilterBar();
319  void showStatusMessage(std::string msg, OpenMS::UInt time);
321  void showCursorStatus(double mz, double rt);
323  void showCursorStatusInvert(double mz, double rt);
325  void showTOPPDialog();
327  void annotateWithAMS();
329  void annotateWithID();
331  void annotateWithOSW();
333  void showSpectrumGenerationDialog();
335  void showSpectrumAlignmentDialog();
337  void showCurrentPeaksAs2D();
339  void showCurrentPeaksAs3D();
341  void showCurrentPeaksAsIonMobility();
343  void showCurrentPeaksAsDIA();
345  void saveLayerAll();
347  void saveLayerVisible();
349  void toggleGridLines();
351  void toggleAxisLegends();
353  void toggleInterestingMZs();
355  void showPreferences();
357  void metadataFileDialog();
358 
362  void setDrawMode1D(int);
363  void setIntensityMode(int);
364  void changeLayerFlag(bool);
365  void changeLabel(QAction*);
366  void changeUnassigned(QAction*);
367  void resetZoom();
368  void toggleProjections();
370 
373  void openFile(const String& filename);
374 
376  void layerFilterVisibilityChange(bool);
377 
379  void showSpectrumMetaData(int spectrum_index);
380 
381 protected slots:
383  void finishTOPPToolExecution(int exitCode, QProcess::ExitStatus exitStatus);
385  void abortTOPPTool();
387  void showSpectrumBrowser();
388 
393  void closeByTab(int id);
395  void showWindow(int id);
397  void copyLayer(const QMimeData* data, QWidget* source, int id = -1);
399 
401  void updateProcessLog();
402 
404  void fileChanged_(const String&);
405 protected:
407  void initializeDefaultParameters_();
408 
412  QStringList chooseFilesDialog_(const String& path_overwrite = "");
413 
415 
416  QDockWidget* layer_dock_widget_;
417  QDockWidget* views_dockwidget_;
418  QDockWidget* filter_dock_widget_;
420 
423 
425 
427 
430 
432  FileWatcher* watcher_ = nullptr;
433 
435  bool watcher_msgbox_ = false;
436 
438  bool zoom_together_ = false;
439 
442 
447 
451  QToolBar* tool_bar_;
452 
453  // common intensity modes
454  QButtonGroup* intensity_button_group_;
455 
456  // 1D specific stuff
457  QToolBar* tool_bar_1d_;
458  QButtonGroup* draw_group_1d_;
459 
460  // 2D specific stuff
461  QToolBar* tool_bar_2d_peak_;
462  QToolBar* tool_bar_2d_feat_;
463  QToolBar* tool_bar_2d_cons_;
466  QAction* dm_hull_2d_;
467  QAction* dm_hulls_2d_;
468  QToolButton* dm_label_2d_;
469  QActionGroup* group_label_2d_;
470  QToolButton* dm_unassigned_2d_;
471  QActionGroup* group_unassigned_2d_;
472  QAction* dm_elements_2d_;
473  QAction* projections_2d_;
474  QAction* dm_ident_2d_;
476 
478  EnhancedWorkspace ws_; // not a pointer, but an actual object, so it gets destroyed before the DefaultParamhandler (on which it depends)
482  RecentFilesMenu recent_files_; // needs to be declared before 'menu_', because its needed there
485 
490  QLabel* message_label_;
492  QLabel* mz_label_;
494  QLabel* rt_label_;
496 
498 
499  void addRecentFile_(const String& filename);
501 
503 
504 
506 
507  void runTOPPTool_();
510  struct
511  {
512  Param param;
513  String tool;
514  String in;
515  String out;
516  String file_name;
517  String layer_name;
518  UInt window_id;
519  Size spectrum_id;
520  QProcess* process = nullptr;
521  QTime timer;
522  bool visible_area_only;
523  } topp_;
525 
529 
530  void closeEvent(QCloseEvent* event) override;
532 
535 
537  void showTOPPDialog_(bool visible);
538 
542 
544  void addToolParamsToIni_();
545 
546 private:
549  }; //class
550 
551 } //namespace
552 
A container for consensus elements.
Definition: ConsensusMap.h:88
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:93
Convenience tab bar implementation.
Definition: EnhancedTabBar.h:62
Definition: EnhancedWorkspace.h:53
A container for features.
Definition: FeatureMap.h:105
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: LayerData.h:96
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerData.h:159
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerData.h:164
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerData.h:153
DataType
Definition: LayerData.h:103
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerData.h:147
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 experiment.
Definition: MSExperiment.h:80
The representation of a 1D spectrum.
Definition: MSSpectrum.h:71
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:136
Base class for spectrum widgets.
Definition: PlotWidget.h:83
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:61
Main window of TOPPView tool.
Definition: TOPPViewBase.h:127
QDockWidget * filter_dock_widget_
Definition: TOPPViewBase.h:418
LayerData::ExperimentType ExperimentType
Definition: TOPPViewBase.h:146
QDockWidget * views_dockwidget_
Definition: TOPPViewBase.h:417
LayerData::ExperimentSharedPtrType ExperimentSharedPtrType
Definition: TOPPViewBase.h:148
TOPPViewMenu menu_
manages the menu items (active/inactive) and recent files etc
Definition: TOPPViewBase.h:484
TOOL_SCAN
Used for deciding whether new tool/util params should be generated or reused from TOPPView's ini file...
Definition: TOPPViewBase.h:157
QLabel * mz_label_
m/z label for messages in the status bar
Definition: TOPPViewBase.h:492
QToolButton * dm_label_2d_
Definition: TOPPViewBase.h:468
QButtonGroup * draw_group_1d_
Definition: TOPPViewBase.h:458
LayerData::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Definition: TOPPViewBase.h:143
ExperimentType::SpectrumType SpectrumType
Peak spectrum type.
Definition: TOPPViewBase.h:152
QToolBar * tool_bar_2d_feat_
Definition: TOPPViewBase.h:462
LayerData::FeatureMapSharedPtrType FeatureMapSharedPtrType
Definition: TOPPViewBase.h:138
static const String CAPTION_3D_SUFFIX_
Suffix appended to caption of tabs when layer is shown in 3D.
Definition: TOPPViewBase.h:548
EnhancedTabBar tab_bar_
Tab bar. The address of the corresponding window to a tab is stored as an int in tabData()
Definition: TOPPViewBase.h:480
QActionGroup * group_label_2d_
Definition: TOPPViewBase.h:469
TVToolDiscovery tool_scanner_
Scans for tools/utils and generates a param for each.
Definition: TOPPViewBase.h:446
FilterList * filter_list_
Definition: TOPPViewBase.h:428
QAction * dm_precursors_2d_
Definition: TOPPViewBase.h:465
LayerData::ConsensusMapType ConsensusMapType
Definition: TOPPViewBase.h:141
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:454
QActionGroup * group_unassigned_2d_
Definition: TOPPViewBase.h:471
QAction * dm_hull_2d_
Definition: TOPPViewBase.h:466
DataSelectionTabs * selection_view_
Definition: TOPPViewBase.h:424
QAction * dm_ident_2d_
Definition: TOPPViewBase.h:474
QAction * dm_hulls_2d_
Definition: TOPPViewBase.h:467
EnhancedWorkspace ws_
Main workspace.
Definition: TOPPViewBase.h:478
QToolBar * tool_bar_2d_peak_
Definition: TOPPViewBase.h:461
QAction * dm_elements_2d_
Definition: TOPPViewBase.h:472
TOOL_SCAN scan_mode_
Determines TVToolDiscovery scans for tool/utils and generates new params.
Definition: TOPPViewBase.h:444
LayerData::FeatureMapType FeatureMapType
Definition: TOPPViewBase.h:136
RecentFilesMenu recent_files_
manages recent list of filenames and the menu that goes with it
Definition: TOPPViewBase.h:482
QAction * projections_2d_
Definition: TOPPViewBase.h:473
QLabel * message_label_
Label for messages in the status bar.
Definition: TOPPViewBase.h:490
QMenu * add_2d_context_
Additional context menu for 2D layers.
Definition: TOPPViewBase.h:534
LayerListView * layers_view_
Layer management widget.
Definition: TOPPViewBase.h:422
LOAD_RESULT
Definition: TOPPViewBase.h:175
QToolBar * tool_bar_
Definition: TOPPViewBase.h:451
QToolBar * tool_bar_2d_cons_
Definition: TOPPViewBase.h:463
QToolButton * dm_unassigned_2d_
Definition: TOPPViewBase.h:470
LayerData::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: TOPPViewBase.h:150
String current_path_
Definition: TOPPViewBase.h:541
QLabel * rt_label_
RT label for messages in the status bar.
Definition: TOPPViewBase.h:494
QToolBar * tool_bar_1d_
Definition: TOPPViewBase.h:457
QToolBar * tool_bar_2d_ident_
Definition: TOPPViewBase.h:464
QDockWidget * layer_dock_widget_
Definition: TOPPViewBase.h:416
LogWindow * log_
Log output window.
Definition: TOPPViewBase.h:441
The file menu items for TOPPView.
Definition: TOPPViewMenu.h:84
Scans for tools/utils and generates a param for each asynchronously.
Definition: TVToolDiscovery.h:62
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:47