OpenMS  3.0.0
TOPPViewMenu.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-2022.
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: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
44 
45 #include <QObject>
46 
47 #include <vector>
48 
49 class QAction;
50 class QMenu;
51 
52 namespace OpenMS
53 {
54  class TOPPViewBase;
55  class EnhancedWorkspace;
56  class RecentFilesMenu;
57 
58  enum class TV_STATUS
59  {
60  HAS_CANVAS,
61  HAS_LAYER,
62  HAS_MIRROR_MODE, // implies 1D View
63  IS_1D_VIEW,
64  TOPP_IDLE
65  };
66 
69  FS_TV OPENMS_GUI_DLLAPI operator+(const TV_STATUS left, const TV_STATUS right);
70 
73  FS_LAYER OPENMS_GUI_DLLAPI operator+(const LayerDataBase::DataType left, const LayerDataBase::DataType right);
74 
75 
83  : public QObject
84  {
85  Q_OBJECT
86  public:
93  TOPPViewMenu(TOPPViewBase* const parent, EnhancedWorkspace* const ws, RecentFilesMenu* const recent_files);
94 
96  void addWindowToggle(QAction* const window_toggle);
97 
98  public slots:
100  void update(const FS_TV status, const LayerDataBase::DataType layer_type);
101 
102  private:
104  {
105  ActionRequirement_(QAction* action, const FS_TV& needs, const FS_LAYER layer_set)
106  : action_(action), needs_(needs), layer_set_(layer_set) {}
107  ActionRequirement_(QAction* action, const TV_STATUS& needs, const FS_LAYER layer_set)
108  : action_(action), needs_(needs), layer_set_(layer_set) {}
109 
113  void enableAction(const FS_TV status, const LayerDataBase::DataType layer_type);
114 
115  private:
116  QAction* action_;
119  };
120 
124  QAction* addAction_(QAction* action, const TV_STATUS req, const FS_LAYER layer_set = FS_LAYER());
126  QAction* addAction_(QAction* action, const FS_TV req, const FS_LAYER layer_set = FS_LAYER());
127 
129  std::vector<ActionRequirement_> menu_items_;
130 
132  QMenu* m_windows_;
133  };
134 
135 } //namespace
136 
QObject
OpenMS::EnhancedWorkspace
Definition: EnhancedWorkspace.h:51
OpenMS::TV_STATUS::HAS_LAYER
OpenMS::TOPPViewMenu::m_windows_
QMenu * m_windows_
the windows submenu (holds all windows added via addWindowToggle())
Definition: TOPPViewMenu.h:132
OpenMS::TOPPViewBase
Main window of TOPPView tool.
Definition: TOPPViewBase.h:126
OpenMS::TOPPViewMenu::ActionRequirement_::ActionRequirement_
ActionRequirement_(QAction *action, const FS_TV &needs, const FS_LAYER layer_set)
Definition: TOPPViewMenu.h:105
OpenMS::TOPPViewMenu::ActionRequirement_::enableAction
void enableAction(const FS_TV status, const LayerDataBase::DataType layer_type)
OpenMS::LayerDataBase::DataType
DataType
Definition: LayerDataBase.h:104
OpenMS::TV_STATUS
TV_STATUS
Definition: TOPPViewMenu.h:58
OpenMS::operator+
FS_TV operator+(const TV_STATUS left, const TV_STATUS right)
allow + operations on the enum, e.g. 'HAS_CANVAS + HAS_LAYER + IS_1D_VIEW'
OpenMS::TV_STATUS::IS_1D_VIEW
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::TV_STATUS::HAS_CANVAS
OpenMS::TOPPViewMenu::ActionRequirement_::ActionRequirement_
ActionRequirement_(QAction *action, const TV_STATUS &needs, const FS_LAYER layer_set)
Definition: TOPPViewMenu.h:107
OpenMS::RecentFilesMenu
Manages recent files opened by the user and provides a QMenu to go with it.
Definition: RecentFilesMenu.h:59
OpenMS::TV_STATUS::HAS_MIRROR_MODE
OpenMS::TOPPViewMenu
The file menu items for TOPPView.
Definition: TOPPViewMenu.h:82
OpenMS::TOPPViewMenu::menu_items_
std::vector< ActionRequirement_ > menu_items_
holds all actions which have a set of requirements, i.e. depend on the state of TOPPViewBase
Definition: TOPPViewMenu.h:129
OpenMS::TOPPViewMenu::ActionRequirement_::needs_
FS_TV needs_
Definition: TOPPViewMenu.h:117
OpenMS::TOPPViewMenu::TOPPViewMenu
TOPPViewMenu(TOPPViewBase *const parent, EnhancedWorkspace *const ws, RecentFilesMenu *const recent_files)
Constructor which connects slots/signals of this class with the objects given as arguments.
LayerDataBase.h
OpenMS::TOPPViewMenu::update
void update(const FS_TV status, const LayerDataBase::DataType layer_type)
enable/disable entries according to a given state of TOPPViewBase
OpenMS::FS_LAYER
FlagSet< LayerDataBase::DataType > FS_LAYER
Definition: TOPPViewMenu.h:71
OpenMS::FlagSet< TV_STATUS >
OpenMS::TV_STATUS::TOPP_IDLE
OpenMS::TOPPViewMenu::ActionRequirement_
Definition: TOPPViewMenu.h:103
FlagSet.h
OpenMS::TOPPViewMenu::addAction_
QAction * addAction_(QAction *action, const TV_STATUS req, const FS_LAYER layer_set=FS_LAYER())
OpenMS::TOPPViewMenu::addWindowToggle
void addWindowToggle(QAction *const window_toggle)
add a menu entry at 'Windows -> [Windowname]' to allow hiding/showing a TOPPView subwindow (e....
OpenMS::TOPPViewMenu::ActionRequirement_::layer_set_
FS_LAYER layer_set_
Definition: TOPPViewMenu.h:118
StandardTypes.h
EnhancedWorkspace.h
OpenMS::TOPPViewMenu::ActionRequirement_::action_
QAction * action_
Definition: TOPPViewMenu.h:116