Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
mitkQuestion.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 mitkQuestion_h
14 #define mitkQuestion_h
15 
16 #include <mitkFileSystem.h>
17 #include <MitkFormsExports.h>
18 
19 #include <string>
20 #include <vector>
21 
22 #include <nlohmann/json_fwd.hpp>
23 
24 namespace mitk::Forms
25 {
32  {
33  public:
34  Question();
35  virtual ~Question();
36 
39  std::string GetQuestionText() const;
40 
43  void SetQuestionText(const std::string& question);
44 
47  bool IsRequired() const;
48 
53  void SetRequired(bool required = true);
54 
63  virtual std::string GetRequiredText() const;
64 
72  virtual bool HasFileResponses() const;
73 
83  virtual std::vector<fs::path> SubmitFileResponses(const fs::path& basePath) const;
84 
117  virtual std::string GetType() const = 0;
118 
133  virtual Question* CreateAnother() const = 0;
134 
150  virtual std::vector<std::string> GetResponsesAsStrings() const = 0;
151 
154  virtual void ClearResponses() = 0;
155 
161  virtual bool IsComplete() const = 0;
162 
181  virtual void FromJSON(const nlohmann::ordered_json& j) = 0;
182 
201  virtual void ToJSON(nlohmann::ordered_json& j) const = 0;
202 
205  private:
206  std::string m_QuestionText;
207  bool m_IsRequired;
208  };
209 
232  MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json& j, Question& q);
233 
256  MITKFORMS_EXPORT void to_json(nlohmann::ordered_json& j, const Question& q);
257 }
258 
259 #endif
mitk::FromJSON
MITKCORE_EXPORT void FromJSON(const nlohmann::json &j, AffineTransform3D::Pointer transform)
Read transform from JSON array (16 elements, resp. 4x4 matrix).
mitk::Forms::to_json
MITKFORMS_EXPORT void to_json(nlohmann::ordered_json &j, const CheckboxesQuestion &q)
mitk::Forms
Definition: mitkCheckboxesQuestion.h:18
mitk::Forms::from_json
MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json &j, CheckboxesQuestion &q)
MitkFormsExports.h
mitk::ToJSON
MITKCORE_EXPORT void ToJSON(nlohmann::json &j, AffineTransform3D::ConstPointer transform)
Write transform (4x4 matrix) as JSON array with 16 elements.
mitk::Forms::Question
Abstract base class for all types of questions used in a Form.
Definition: mitkQuestion.h:31
MITKFORMS_EXPORT
#define MITKFORMS_EXPORT
Definition: MitkFormsExports.h:15
mitkFileSystem.h