Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkFileReaderWriterOptionsWidget.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkFileReaderWriterOptionsWidget_h
14 #define QmitkFileReaderWriterOptionsWidget_h
15 
16 #include <QCheckBox>
17 #include <QComboBox>
18 #include <QDoubleSpinBox>
19 #include <QLabel>
20 #include <QLineEdit>
21 #include <QSpinBox>
22 #include <QWidget>
23 
24 #include <usAny.h>
25 
35 {
40  QmitkAnyAdapter(const std::string &name) : m_Name(name) {}
41  virtual ~QmitkAnyAdapter() {}
42 
47  virtual us::Any GetAny() const = 0;
48 
53  std::string GetName() const { return m_Name; }
54 private:
55  std::string m_Name;
56 };
57 
62 class QmitkAnyStringWidget : public QLineEdit, public QmitkAnyAdapter
63 {
64  Q_OBJECT
65 
66 public:
73  QmitkAnyStringWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
74 
76  us::Any GetAny() const override;
77 };
78 
83 class QmitkAnyVectorWidget : public QComboBox, public QmitkAnyAdapter
84 {
85  Q_OBJECT
86 
87 public:
95  QmitkAnyVectorWidget(const std::string &name,
96  const us::Any &any,
97  const QString &defaultValue,
98  QWidget *parent = nullptr);
99 
101  us::Any GetAny() const override;
102 };
103 
108 class QmitkAnyBoolWidget : public QCheckBox, public QmitkAnyAdapter
109 {
110  Q_OBJECT
111 
112 public:
119  QmitkAnyBoolWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
120 
122  us::Any GetAny() const override;
123 };
124 
129 class QmitkAnyShortWidget : public QSpinBox, public QmitkAnyAdapter
130 {
131  Q_OBJECT
132 
133 public:
140  QmitkAnyShortWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
141 
143  us::Any GetAny() const override;
144 };
145 
150 class QmitkAnyUShortWidget : public QSpinBox, public QmitkAnyAdapter
151 {
152  Q_OBJECT
153 
154 public:
161  QmitkAnyUShortWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
162 
164  us::Any GetAny() const override;
165 };
166 
171 class QmitkAnyIntWidget : public QSpinBox, public QmitkAnyAdapter
172 {
173  Q_OBJECT
174 
175 public:
182  QmitkAnyIntWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
183 
185  us::Any GetAny() const override;
186 };
187 
192 class QmitkAnyUIntWidget : public QSpinBox, public QmitkAnyAdapter
193 {
194  Q_OBJECT
195 
196 public:
203  QmitkAnyUIntWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
204 
206  us::Any GetAny() const override;
207 };
208 
213 class QmitkAnyFloatWidget : public QDoubleSpinBox, public QmitkAnyAdapter
214 {
215  Q_OBJECT
216 
217 public:
224  QmitkAnyFloatWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
225 
227  us::Any GetAny() const override;
228 };
229 
234 class QmitkAnyDoubleWidget : public QDoubleSpinBox, public QmitkAnyAdapter
235 {
236  Q_OBJECT
237 
238 public:
245  QmitkAnyDoubleWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
246 
248  us::Any GetAny() const override;
249 };
250 
259 class QmitkInvalidAnyWidget : public QLabel, public QmitkAnyAdapter
260 {
261  Q_OBJECT
262 
263 public:
270  QmitkInvalidAnyWidget(const std::string &name, const us::Any &any, QWidget *parent = nullptr);
271 
273  us::Any GetAny() const override;
274 };
275 
289 {
290  Q_OBJECT
291 
292 public:
294  typedef std::map<std::string, us::Any> Options;
295 
301  QmitkFileReaderWriterOptionsWidget(const Options &options, QWidget *parent = nullptr);
302 
308 
309 private:
310  Q_DISABLE_COPY(QmitkFileReaderWriterOptionsWidget)
311 };
312 
313 #endif
A QCheckBox-based adapter for boolean options.
QmitkAnyBoolWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs a boolean option widget.
us::Any GetAny() const override
Returns the current check state as a us::Any.
A QDoubleSpinBox-based adapter for double-precision options.
us::Any GetAny() const override
Returns the current value as a us::Any wrapping a double.
QmitkAnyDoubleWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs a double-precision option widget.
A QDoubleSpinBox-based adapter for float options.
QmitkAnyFloatWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs a float option widget.
us::Any GetAny() const override
Returns the current value as a us::Any wrapping a float.
A QSpinBox-based adapter for signed integer options.
QmitkAnyIntWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs a signed integer option widget.
us::Any GetAny() const override
Returns the current value as a us::Any wrapping an int.
A QSpinBox-based adapter for short integer options.
QmitkAnyShortWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs a short integer option widget.
us::Any GetAny() const override
Returns the current value as a us::Any wrapping a short.
A QLineEdit-based adapter for string-valued options.
us::Any GetAny() const override
Returns the current text as a us::Any.
QmitkAnyStringWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs a string option widget.
A QSpinBox-based adapter for unsigned integer options.
us::Any GetAny() const override
Returns the current value as a us::Any wrapping an unsigned int.
QmitkAnyUIntWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs an unsigned integer option widget.
A QSpinBox-based adapter for unsigned short integer options.
us::Any GetAny() const override
Returns the current value as a us::Any wrapping an unsigned short.
QmitkAnyUShortWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs an unsigned short integer option widget.
A QComboBox-based adapter for vector-of-string options.
us::Any GetAny() const override
Returns the currently selected item as a us::Any.
QmitkAnyVectorWidget(const std::string &name, const us::Any &any, const QString &defaultValue, QWidget *parent=nullptr)
Constructs a vector option widget with a combo box.
A widget that dynamically creates typed editor widgets for file reader/writer options.
QmitkFileReaderWriterOptionsWidget(const Options &options, QWidget *parent=nullptr)
Constructs the widget, creating editor sub-widgets for each option.
Options GetOptions() const
Returns the current option values from all editor widgets.
std::map< std::string, us::Any > Options
Type alias for the options map (option name to us::Any).
A QLabel-based adapter for options of unsupported types.
QmitkInvalidAnyWidget(const std::string &name, const us::Any &any, QWidget *parent=nullptr)
Constructs a read-only label for an unsupported option type.
us::Any GetAny() const override
Returns the original us::Any value unchanged.
An Any class represents a general type and is capable of storing any type, supporting type-safe extra...
Definition: usAny.h:145
Abstract adapter interface for converting Qt widget values to us::Any.
std::string GetName() const
Returns the option name associated with this adapter.
QmitkAnyAdapter(const std::string &name)
Constructs the adapter with the given option name.
virtual us::Any GetAny() const =0
Returns the current widget value as a us::Any.