Medical Imaging Interaction Toolkit  2025.12.02
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:
32 
33  std::vector<std::string> GetResponsesAsStrings() const override;
34  void ClearResponses() override;
35 
36  bool IsComplete() const override;
37 
44  size_t AddOption(const std::string& option);
45 
46  std::vector<std::string> GetOptions() const;
47 
48  protected:
55  void AddResponse(size_t i);
56 
61  void RemoveResponse(size_t i);
62 
67  virtual void SetResponse(size_t i);
68 
69  private:
70  std::vector<std::string> m_Options;
71  std::set<size_t> m_Responses;
72  };
73 
74  MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json& j, QuestionWithOptions& q);
75  MITKFORMS_EXPORT void to_json(nlohmann::ordered_json& j, const QuestionWithOptions& q);
76 }
77 
78 #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 if a question is considered to be answered completely.
void RemoveResponse(size_t i)
Remove one of the already given responses.
void ClearResponses() override
Clear the/all response(s).
std::vector< std::string > GetOptions() const
std::vector< std::string > GetResponsesAsStrings() const override
Return the question's response(s) as strings.
Abstract base class for all types of questions used in a Form.
Definition: mitkQuestion.h:32
MITKFORMS_EXPORT void to_json(nlohmann::ordered_json &j, const CheckboxesQuestion &q)
MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json &j, CheckboxesQuestion &q)