Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkQuestionWithOptions.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 mitkQuestionWithOptions_h
14 #define mitkQuestionWithOptions_h
15 
16 #include <mitkQuestion.h>
17 #include <set>
18 
19 namespace mitk::Forms
20 {
29  {
30  public:
34 
42  std::vector<std::string> GetResponsesAsStrings() const override;
43 
46  void ClearResponses() override;
47 
52  bool IsComplete() const override;
53 
61  size_t AddOption(const std::string& option);
62 
67  std::vector<std::string> GetOptions() const;
68 
69  protected:
78  void AddResponse(size_t i);
79 
86  void RemoveResponse(size_t i);
87 
94  virtual void SetResponse(size_t i);
95 
96  private:
97  std::vector<std::string> m_Options;
98  std::set<size_t> m_Responses;
99  };
100 
110  MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json& j, QuestionWithOptions& q);
111 
121  MITKFORMS_EXPORT void to_json(nlohmann::ordered_json& j, const QuestionWithOptions& q);
122 }
123 
124 #endif
#define MITKFORMS_EXPORT
Base class for questions with options to choose from as response.
virtual void SetResponse(size_t i)
Set one of the possible answer options as the single response.
size_t AddOption(const std::string &option)
Add a non-exclusive option as possible answer to the question.
void AddResponse(size_t i)
Add one of the possible answer options to the responses.
bool IsComplete() const override
Check whether at least one option has been selected.
~QuestionWithOptions() override
Virtual destructor.
void RemoveResponse(size_t i)
Remove one of the already given responses.
void ClearResponses() override
Clear all selected responses.
std::vector< std::string > GetOptions() const
Get all available options.
std::vector< std::string > GetResponsesAsStrings() const override
Return the selected options as strings.
Abstract base class for all types of questions used in a Form.
Definition: mitkQuestion.h:38
MITKFORMS_EXPORT void to_json(nlohmann::ordered_json &j, const CheckboxesQuestion &q)
Serialize a CheckboxesQuestion to JSON.
MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json &j, CheckboxesQuestion &q)
Deserialize a CheckboxesQuestion from JSON.