Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkLinearScaleQuestion.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 mitkLinearScaleQuestion_h
14 #define mitkLinearScaleQuestion_h
15 
16 #include <mitkQuestion.h>
17 #include <optional>
18 #include <utility>
19 
20 namespace mitk::Forms
21 {
31  {
32  public:
38 
42 
47  std::string GetType() const override;
48 
53  Question* CreateAnother() const override;
54 
59  void FromJSON(const nlohmann::ordered_json& j) override;
60 
65  void ToJSON(nlohmann::ordered_json& j) const override;
66 
72  std::vector<std::string> GetResponsesAsStrings() const override;
73 
76  void ClearResponses() override;
77 
82  bool IsComplete() const override;
83 
88  std::optional<int> GetResponse() const;
89 
94  void SetResponse(int response);
95 
100  std::pair<int, int> GetRange() const;
101 
112  void SetRange(const std::pair<int, int>& range);
113 
118  std::pair<std::string, std::string> GetRangeLabels() const;
119 
125  void SetRangeLabels(const std::pair<std::string, std::string>& labels);
126 
127  private:
128  std::optional<int> m_Response;
129  std::pair<int, int> m_Range;
130  std::pair<std::string, std::string> m_Labels;
131  };
132 
140  MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json& j, LinearScaleQuestion& q);
141 
149  MITKFORMS_EXPORT void to_json(nlohmann::ordered_json& j, const LinearScaleQuestion& q);
150 }
151 
152 #endif
#define MITKFORMS_EXPORT
A Question whose possible responses are represented by a discrete linear scale.
void SetRange(const std::pair< int, int > &range)
Set the allowed range of numbers for a valid response.
bool IsComplete() const override
Check whether a response has been given.
std::string GetType() const override
Return the type string "Linear scale".
void FromJSON(const nlohmann::ordered_json &j) override
Deserialize this LinearScaleQuestion from JSON.
Question * CreateAnother() const override
Create a new default-constructed LinearScaleQuestion instance.
void ClearResponses() override
Clear the response.
std::pair< std::string, std::string > GetRangeLabels() const
Get the labels for the low and high ends of the scale.
std::optional< int > GetResponse() const
Get the current numeric response.
std::pair< int, int > GetRange() const
Get the allowed range.
~LinearScaleQuestion() override
Virtual destructor.
void ToJSON(nlohmann::ordered_json &j) const override
Serialize this LinearScaleQuestion to JSON.
void SetResponse(int response)
Set the numeric response.
std::vector< std::string > GetResponsesAsStrings() const override
Return the numeric response as a single-element vector of strings.
void SetRangeLabels(const std::pair< std::string, std::string > &labels)
Set the labels for the low and high ends of the scale.
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.