Medical Imaging Interaction Toolkit  2024.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkForm.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 mitkForm_h
14 #define mitkForm_h
15 
16 #include <mitkFileSystem.h>
17 #include <MitkFormsExports.h>
18 
19 #include <memory>
20 #include <string>
21 #include <map>
22 #include <vector>
23 
24 #include <nlohmann/json_fwd.hpp>
25 
26 namespace mitk::Forms
27 {
28  class Question;
29 
37  {
38  public:
40  {
41  public:
42  explicit Section(const std::string& title = "", const std::string& description = "");
43  ~Section();
44 
45  Section(Section&& other) noexcept;
46  Section& operator=(Section&& other) noexcept;
47 
48  std::string GetTitle() const;
49  void SetTitle(const std::string& title);
50 
51  std::string GetDescription() const;
52  void SetDescription(const std::string& description);
53 
54  std::vector<Question*> GetQuestions() const;
55  void AddQuestion(Question* question);
56 
57  private:
58  std::string m_Title;
59  std::string m_Description;
60  std::vector<std::unique_ptr<Question>> m_Questions;
61  };
62 
63  explicit Form(const std::string& title = "", const std::string& description = "");
64  ~Form();
65 
66  Form(Form&& other) noexcept;
67  Form& operator=(Form&& other) noexcept;
68 
69  Section& AddSection(const std::string& title = "", const std::string& description = "");
70  int GetNumberOfSections() const;
71 
72  Section& GetSection(int index);
73  const Section& GetSection(int index) const;
74 
75  std::string GetTitle() const;
76  void SetTitle(const std::string& title);
77 
78  std::string GetDescription() const;
79  void SetDescription(const std::string& description);
80 
81  std::vector<Question*> GetQuestions() const;
82  void AddQuestion(Question* question);
83 
96  void AddSupplement(const std::string& key);
97 
104  bool SetSupplement(const std::string& key, const std::string& value);
105 
106  const std::map<std::string, std::string>& GetSupplements() const;
107 
108  std::vector<Section>::const_iterator begin() const;
109  std::vector<Section>::const_iterator end() const;
110 
111  std::vector<Section>::iterator begin();
112  std::vector<Section>::iterator end();
113 
114  private:
115  std::vector<Section> m_Sections;
116  std::map<std::string, std::string> m_Supplements;
117  };
118 
119  MITKFORMS_EXPORT void SubmitToCSV(const Form& form, const fs::path& csvPath);
120 
121  MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json& j, Form& f);
122  MITKFORMS_EXPORT void to_json(nlohmann::ordered_json& j, const Form& f);
123 }
124 
125 #endif
mitk::Forms::Form::Section
Definition: mitkForm.h:39
mitk::Forms::Form
Definition: mitkForm.h:36
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)
mitk::Forms::SubmitToCSV
MITKFORMS_EXPORT void SubmitToCSV(const Form &form, const fs::path &csvPath)
MitkFormsExports.h
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