OpenMS
Loading...
Searching...
No Matches
WizardHelper.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Jihyung Kim $
6// $Authors: Jihyung Kim, Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11namespace OpenMS
12{
13 class InputFile;
14 class OutputDirectory;
15 class ParamEditor;
16
17 namespace Internal
18 {
22 template<class TWidgetClass>
24 {
25 public:
26 WizardGUILock(TWidgetClass* stw):
27 stw_(stw),
28 old_(stw->currentWidget()),
29 glock_(stw)
30 {
31 stw->setCurrentWidget(stw->ui->tab_log);
32 }
33
35 {
36 stw_->setCurrentWidget(old_);
37 }
38
39 private:
40 TWidgetClass* stw_;
43 };
44
46 struct Args
47 {
48 QStringList loop_arg;
49 size_t insert_pos;
50 };
51
52 typedef std::vector<Args> ArgLoop;
53
59 struct Command
60 {
62 QStringList args;
64
65 Command(const String& e, const QStringList& a, const ArgLoop& l) :
66 exe(e),
67 args(a),
68 loop(l) {}
69
72 size_t getLoopCount() const
73 {
74 if (loop.empty()) return 1;
75 size_t common_size = loop[0].loop_arg.size();
76 for (const auto& l : loop)
77 {
78 if (l.loop_arg.size() != (int)common_size) throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Internal error. Not all loop arguments support the same number of loops!");
79 if ((int)l.insert_pos >= args.size()) throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Internal error. Loop argument wants to insert after end of template arguments!");
80 }
81 return common_size;
82 }
85 QStringList getArgs(const int loop_number) const
86 {
87 if (loop_number >= (int)getLoopCount())
88 {
89 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Internal error. The loop number you requested is too high!");
90 }
91 if (loop.empty()) return args; // no looping available
92
93 QStringList arg_l = args;
94 for (const auto& largs : loop) // replace all args for the current round
95 {
96 arg_l[largs.insert_pos] = args[largs.insert_pos].arg(largs.loop_arg[loop_number]);
97 }
98 return arg_l;
99 }
100 };
101
102 }
103} // ns OpenMS
104
105// this is required to allow Ui_[tool_name]TabWidget (auto UIC'd from .ui) to have a InputFile member
Precondition failed exception.
Definition Exception.h:128
RAII class to disable the GUI and set a busy cursor and go back to the original state when this class...
Definition GUIHelpers.h:124
A simple widget with a line-edit and a browse button to choose filenames.
Definition gui/include/OpenMS/VISUAL/InputFile.h:31
RAII class to switch to certain TabWidget, disable the GUI and go back to the orignal Tab when this c...
Definition WizardHelper.h:24
~WizardGUILock()
Definition WizardHelper.h:34
WizardGUILock(TWidgetClass *stw)
Definition WizardHelper.h:26
TWidgetClass * stw_
Definition WizardHelper.h:40
GUIHelpers::GUILock glock_
Definition WizardHelper.h:42
QWidget * old_
Definition WizardHelper.h:41
A simple widget with a line-edit and a browse button to choose filenames.
Definition OutputDirectory.h:31
A GUI for editing or viewing a Param object.
Definition ParamEditor.h:153
A more convenient string class.
Definition String.h:34
A better QTable for TOPPView, which supports exporting to TSV and conveniently adding data to cells a...
Definition TableView.h:22
QStringList loop_arg
list of arguments to insert; one for every loop
Definition WizardHelper.h:48
std::vector< Args > ArgLoop
Definition WizardHelper.h:52
size_t insert_pos
where to insert in the target argument list (index is 0-based)
Definition WizardHelper.h:49
custom arguments to allow for looping calls
Definition WizardHelper.h:47
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition WizardHelper.h:60
QStringList getArgs(const int loop_number) const
Definition WizardHelper.h:85
String exe
Definition WizardHelper.h:61
size_t getLoopCount() const
Definition WizardHelper.h:72
QStringList args
Definition WizardHelper.h:62
ArgLoop loop
Definition WizardHelper.h:63
Command(const String &e, const QStringList &a, const ArgLoop &l)
Definition WizardHelper.h:65